Browse Source

Read local edge.conf and supernode.conf files on Windows

pull/179/head
emanuele-f 5 years ago
parent
commit
0b965c37c0
  1. 27
      doc/Windows.md
  2. 22
      edge.c
  3. 16
      sn.c

27
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" "C:\Program Files\CMake\bin\cmake"
The compiled exe files should now be available under the Release directory. 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.

22
edge.c

@ -621,9 +621,6 @@ int main(int argc, char* argv[]) {
struct passwd *pw = NULL; struct passwd *pw = NULL;
#endif #endif
if(argc == 1)
help();
/* Defaults */ /* Defaults */
edge_init_conf_defaults(&conf); edge_init_conf_defaults(&conf);
memset(&ec, 0, sizeof(ec)); 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.ip_mode, sizeof(ec.ip_mode), "static");
snprintf(ec.netmask, sizeof(ec.netmask), "255.255.255.0"); 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] != '-')) { if((argc >= 2) && (argv[1][0] != '-')) {
rc = loadFromFile(argv[1], &conf, &ec); rc = loadFromFile(argv[1], &conf, &ec);
if(argc > 2) if(argc > 2)
rc = loadFromCLI(argc, argv, &conf, &ec); rc = loadFromCLI(argc, argv, &conf, &ec);
} else } else if(argc > 1)
rc = loadFromCLI(argc, argv, &conf, &ec); 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) if(rc < 0)
help(); 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)) { if(0 == strcmp("dhcp", ec.ip_mode)) {
traceEvent(TRACE_NORMAL, "Dynamic IP address assignment enabled."); traceEvent(TRACE_NORMAL, "Dynamic IP address assignment enabled.");
@ -665,9 +672,6 @@ int main(int argc, char* argv[]) {
} else } else
traceEvent(TRACE_NORMAL, "ip_mode='%s'", ec.ip_mode); traceEvent(TRACE_NORMAL, "ip_mode='%s'", ec.ip_mode);
if(edge_verify_conf(&conf) != 0)
help();
if(!( if(!(
#ifdef __linux__ #ifdef __linux__
(ec.tuntap_dev_name[0] != 0) && (ec.tuntap_dev_name[0] != 0) &&

16
sn.c

@ -746,7 +746,9 @@ static void help() {
printf("supernode "); printf("supernode ");
printf("-l <lport> "); printf("-l <lport> ");
printf("-c <path> "); printf("-c <path> ");
#if defined(N2N_HAVE_DAEMON)
printf("[-f] "); printf("[-f] ");
#endif
printf("[-v] "); printf("[-v] ");
printf("\n\n"); printf("\n\n");
@ -972,20 +974,24 @@ static void term_handler(int sig)
int main(int argc, char * const argv[]) { int main(int argc, char * const argv[]) {
int rc; int rc;
if(argc == 1)
help();
init_sn(&sss_node); init_sn(&sss_node);
if((argc >= 2) && (argv[1][0] != '-')) { if((argc >= 2) && (argv[1][0] != '-')) {
rc = loadFromFile(argv[1], &sss_node); rc = loadFromFile(argv[1], &sss_node);
if(argc > 2) if(argc > 2)
rc = loadFromCLI(argc, argv, &sss_node); rc = loadFromCLI(argc, argv, &sss_node);
} else } else if(argc > 1)
rc = loadFromCLI(argc, argv, &sss_node); 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) if(rc < 0)
return(-1); help();
#if defined(N2N_HAVE_DAEMON) #if defined(N2N_HAVE_DAEMON)
if(sss_node.daemon) { if(sss_node.daemon) {

Loading…
Cancel
Save