X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_setup.c;h=35cd3f7948ab9945653f8a3d08e284b3ee76dab3;hb=9699f08afc6420d2bdac1063ea6789b585aaf42e;hp=64d25150c7cb49fd532aca7f13c20a15fd248af0;hpb=8f8424445810aa7d5e9d4d537494e64811a8e29f;p=tinc diff --git a/src/net_setup.c b/src/net_setup.c index 64d25150..35cd3f79 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -750,7 +750,6 @@ static bool setup_myself(void) { free(cipher); - send_key_changed(); timeout_add(&keyexpire_timeout, keyexpire_handler, &keyexpire_timeout, &(struct timeval){keylifetime, rand() % 100000}); /* Check if we want to use message authentication codes... */ @@ -828,22 +827,6 @@ static bool setup_myself(void) { if(device_fd >= 0) io_add(&device_io, handle_device_data, NULL, device_fd, IO_READ); - /* Run tinc-up script to further initialize the tap interface */ - char *envp[5] = {NULL}; - xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); - xasprintf(&envp[1], "DEVICE=%s", device ? : ""); - xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); - xasprintf(&envp[3], "NAME=%s", myself->name); - - execute_script("tinc-up", envp); - - for(int i = 0; i < 4; i++) - free(envp[i]); - - /* Run subnet-up scripts for our own subnets */ - - subnet_update(myself, NULL, true); - /* Open sockets */ if(!do_detach && getenv("LISTEN_FDS")) { @@ -957,9 +940,7 @@ static bool setup_myself(void) { } while(cfg); } - if(listen_sockets) - logger(DEBUG_ALWAYS, LOG_NOTICE, "Ready"); - else { + if(!listen_sockets) { logger(DEBUG_ALWAYS, LOG_ERR, "Unable to create any listening socket!"); return false; } @@ -997,6 +978,26 @@ bool setup_network(void) { if(!setup_myself()) return false; + if(!init_control()) + return false; + + /* Run tinc-up script to further initialize the tap interface */ + + char *envp[5] = {NULL}; + xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); + xasprintf(&envp[3], "NAME=%s", myself->name); + + execute_script("tinc-up", envp); + + for(int i = 0; i < 4; i++) + free(envp[i]); + + /* Run subnet-up scripts for our own subnets */ + + subnet_update(myself, NULL, true); + return true; } @@ -1050,5 +1051,7 @@ void close_network_connections(void) { devops.close(); + exit_control(); + return; }