|
|
@ -110,6 +110,9 @@ static int scan_address(char * ip_addr, size_t addr_size, |
|
|
|
static void help() { |
|
|
|
print_n2n_version(); |
|
|
|
|
|
|
|
printf("edge <config file> (see edge.conf)\n" |
|
|
|
"or\n" |
|
|
|
); |
|
|
|
printf("edge " |
|
|
|
#if defined(N2N_CAN_NAME_IFACE) |
|
|
|
"-d <tun device> " |
|
|
@ -551,10 +554,12 @@ int main(int argc, char* argv[]) { |
|
|
|
int keep_on_running = 1; |
|
|
|
int rc; |
|
|
|
int i; |
|
|
|
|
|
|
|
n2n_edge_t eee; /* single instance for this program */ |
|
|
|
edge_conf_t ec; |
|
|
|
|
|
|
|
if(argc == 1) |
|
|
|
help(); |
|
|
|
|
|
|
|
ec.local_port = 0 /* any port */; |
|
|
|
ec.mgmt_port = N2N_EDGE_MGMT_PORT; /* 5644 by default */ |
|
|
|
snprintf(ec.tuntap_dev_name, sizeof(ec.tuntap_dev_name), "edge0"); |
|
|
@ -570,14 +575,12 @@ int main(int argc, char* argv[]) { |
|
|
|
ec.groupid = 0; /* root is the only guaranteed ID */ |
|
|
|
#endif |
|
|
|
|
|
|
|
if(-1 == edge_init(&eee)) |
|
|
|
{ |
|
|
|
if(-1 == edge_init(&eee)) { |
|
|
|
traceEvent(TRACE_ERROR, "Failed in edge_init"); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
if(getenv("N2N_KEY")) |
|
|
|
{ |
|
|
|
if(getenv("N2N_KEY")) { |
|
|
|
ec.encrypt_key = strdup(getenv("N2N_KEY")); |
|
|
|
} |
|
|
|
|
|
|
@ -596,19 +599,12 @@ int main(int argc, char* argv[]) { |
|
|
|
#endif |
|
|
|
rc = loadFromCLI(argc, argv, &ec, &eee); |
|
|
|
|
|
|
|
if(rc < 0) |
|
|
|
return(-1); |
|
|
|
|
|
|
|
#ifndef WIN32 |
|
|
|
if(eee.daemon) { |
|
|
|
useSyslog = 1; /* traceEvent output now goes to syslog. */ |
|
|
|
daemonize(); |
|
|
|
} |
|
|
|
#endif /* #ifndef WIN32 */ |
|
|
|
if((rc < 0) || (eee.sn_num == 0)) |
|
|
|
help(); |
|
|
|
|
|
|
|
traceEvent(TRACE_NORMAL, "Starting n2n edge %s %s", n2n_sw_version, n2n_sw_buildDate); |
|
|
|
|
|
|
|
for (i=0; i< N2N_EDGE_NUM_SUPERNODES; ++i) |
|
|
|
for (i=0; i<eee.sn_num; ++i) |
|
|
|
traceEvent(TRACE_NORMAL, "supernode %u => %s\n", i, (eee.sn_ip_array[i])); |
|
|
|
|
|
|
|
supernode2addr(&(eee.supernode), eee.sn_ip_array[eee.sn_idx]); |
|
|
@ -624,6 +620,13 @@ int main(int argc, char* argv[]) { |
|
|
|
help(); |
|
|
|
} |
|
|
|
|
|
|
|
#ifndef WIN32 |
|
|
|
if(eee.daemon) { |
|
|
|
useSyslog = 1; /* traceEvent output now goes to syslog. */ |
|
|
|
daemonize(); |
|
|
|
} |
|
|
|
#endif /* #ifndef WIN32 */ |
|
|
|
|
|
|
|
if((NULL == ec.encrypt_key) && (0 == strlen(eee.keyschedule))) |
|
|
|
{ |
|
|
|
traceEvent(TRACE_WARNING, "Encryption is disabled in edge."); |
|
|
|