diff --git a/doc/Windows.md b/doc/Windows.md index 19bc0f2..b95fdc6 100644 --- a/doc/Windows.md +++ b/doc/Windows.md @@ -42,3 +42,30 @@ NOTE: if cmake has problems finding the installed OpenSSL library, try to downlo "C:\Program Files\CMake\bin\cmake" The compiled exe files should now be available under the Release directory. + +# Run + +The `edge.exe` program reads the `edge.conf` file located into the current directory if no option is provided. + +Here is an example `edge.conf` file: + +``` +-c=mycommunity +-k=mysecretkey + +# supernode IP address +-l=1.2.3.4:5678 + +# edge IP address +-a=192.168.100.1 +``` + +The `supernode.exe` program reads the `supernode.conf` file located into the current directory if no option is provided. + +Here is an example `supernode.conf` file: + +``` +-l=5678 +``` + +See `edge.exe --help` and `supernode.exe --help` for a list of supported options. diff --git a/edge.c b/edge.c index 9e5a7d7..3cc6ce3 100644 --- a/edge.c +++ b/edge.c @@ -621,9 +621,6 @@ int main(int argc, char* argv[]) { struct passwd *pw = NULL; #endif - if(argc == 1) - help(); - /* Defaults */ edge_init_conf_defaults(&conf); memset(&ec, 0, sizeof(ec)); @@ -646,18 +643,28 @@ int main(int argc, char* argv[]) { snprintf(ec.ip_mode, sizeof(ec.ip_mode), "static"); snprintf(ec.netmask, sizeof(ec.netmask), "255.255.255.0"); - traceEvent(TRACE_NORMAL, "Starting n2n edge %s %s", PACKAGE_VERSION, PACKAGE_BUILDDATE); - if((argc >= 2) && (argv[1][0] != '-')) { rc = loadFromFile(argv[1], &conf, &ec); if(argc > 2) rc = loadFromCLI(argc, argv, &conf, &ec); - } else + } else if(argc > 1) rc = loadFromCLI(argc, argv, &conf, &ec); + else +#ifdef WIN32 + /* Load from current directory */ + rc = loadFromFile("edge.conf", &conf, &ec); +#else + rc = -1; +#endif if(rc < 0) help(); + if(edge_verify_conf(&conf) != 0) + help(); + + traceEvent(TRACE_NORMAL, "Starting n2n edge %s %s", PACKAGE_VERSION, PACKAGE_BUILDDATE); + if(0 == strcmp("dhcp", ec.ip_mode)) { traceEvent(TRACE_NORMAL, "Dynamic IP address assignment enabled."); @@ -665,9 +672,6 @@ int main(int argc, char* argv[]) { } else traceEvent(TRACE_NORMAL, "ip_mode='%s'", ec.ip_mode); - if(edge_verify_conf(&conf) != 0) - help(); - if(!( #ifdef __linux__ (ec.tuntap_dev_name[0] != 0) && diff --git a/sn.c b/sn.c index 96810fa..f817321 100644 --- a/sn.c +++ b/sn.c @@ -746,7 +746,9 @@ static void help() { printf("supernode "); printf("-l "); printf("-c "); +#if defined(N2N_HAVE_DAEMON) printf("[-f] "); +#endif printf("[-v] "); printf("\n\n"); @@ -972,20 +974,24 @@ static void term_handler(int sig) int main(int argc, char * const argv[]) { int rc; - if(argc == 1) - help(); - init_sn(&sss_node); if((argc >= 2) && (argv[1][0] != '-')) { rc = loadFromFile(argv[1], &sss_node); if(argc > 2) rc = loadFromCLI(argc, argv, &sss_node); - } else + } else if(argc > 1) rc = loadFromCLI(argc, argv, &sss_node); + else +#ifdef WIN32 + /* Load from current directory */ + rc = loadFromFile("supernode.conf", &sss_node); +#else + rc = -1; +#endif if(rc < 0) - return(-1); + help(); #if defined(N2N_HAVE_DAEMON) if(sss_node.daemon) {