Add the ListenAddress option.
[tinc] / src / tincctl.c
index 956771f..c6d7582 100644 (file)
@@ -68,10 +68,6 @@ bool netnamegiven = false;
 char *scriptinterpreter = NULL;
 char *scriptextension = "";
 
-#ifdef HAVE_MINGW
-static struct WSAData wsa_state;
-#endif
-
 static struct option const long_options[] = {
        {"config", required_argument, NULL, 'c'},
        {"net", required_argument, NULL, 'n'},
@@ -682,14 +678,6 @@ bool connect_tincd(bool verbose) {
 
        fclose(f);
 
-#ifdef HAVE_MINGW
-       if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) {
-               if(verbose)
-                       fprintf(stderr, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError()));
-               return false;
-       }
-#endif
-
 #ifndef HAVE_MINGW
        struct sockaddr_un sa;
        sa.sun_family = AF_UNIX;
@@ -1304,6 +1292,7 @@ const var_t variables[] = {
        {"IffOneQueue", VAR_SERVER},
        {"Interface", VAR_SERVER},
        {"KeyExpire", VAR_SERVER},
+       {"ListenAddress", VAR_SERVER | VAR_MULTIPLE},
        {"LocalDiscovery", VAR_SERVER},
        {"MACExpire", VAR_SERVER},
        {"MaxConnectionBurst", VAR_SERVER},
@@ -1618,7 +1607,7 @@ static int cmd_config(int argc, char *argv[]) {
        if(action < 0 && !removed) {
                remove(tmpfile);
                fprintf(stderr, "No configuration variables deleted.\n");
-               return *value;
+               return *value != 0;
        }
 
        // Replace the configuration file with the new one
@@ -1751,7 +1740,7 @@ static int cmd_init(int argc, char *argv[]) {
                return 1;
        }
 
-       if(strcmp(confdir, confbase) && mkdir(confdir, 0755) && errno != EEXIST) {
+       if(!confbase_given && mkdir(confdir, 0755) && errno != EEXIST) {
                fprintf(stderr, "Could not create directory %s: %s\n", confdir, strerror(errno));
                return 1;
        }
@@ -1789,7 +1778,7 @@ static int cmd_init(int argc, char *argv[]) {
                        fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno));
                        return 1;
                }
-               fprintf(f, "#!/bin/sh\n\necho 'Unconfigured tinc-up script, please edit!'\n\n#ifconfig $INTERFACE <your vpn IP address> netmask <netmask of whole VPN>\n");
+               fprintf(f, "#!/bin/sh\n\necho 'Unconfigured tinc-up script, please edit '$0'!'\n\n#ifconfig $INTERFACE <your vpn IP address> netmask <netmask of whole VPN>\n");
                fclose(f);
        }
 #endif
@@ -2366,6 +2355,15 @@ int main(int argc, char *argv[]) {
                return 0;
        }
 
+#ifdef HAVE_MINGW
+       static struct WSAData wsa_state;
+
+       if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) {
+               fprintf(stderr, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError()));
+               return false;
+       }
+#endif
+
        srand(time(NULL));
        crypto_init();