/*
net_setup.c -- Setup.
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2016 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
2010 Brandon Black <blblack@gmail.com>
#endif
char *myport;
-static char *myname;
static io_t device_io;
devops_t devops;
bool device_standby = false;
invitation_key = NULL;
}
- snprintf(fname, sizeof fname, "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase);
+ snprintf(fname, sizeof(fname), "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase);
fp = fopen(fname, "r");
struct dirent *ent;
char dname[PATH_MAX];
- snprintf(dname, sizeof dname, "%s" SLASH "hosts", confbase);
+ snprintf(dname, sizeof(dname), "%s" SLASH "hosts", confbase);
dir = opendir(dname);
if(!dir) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", dname, strerror(errno));
get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);
+ if(!get_config_int(lookup_config(config_tree, "InvitationExpire"), &invitation_lifetime))
+ invitation_lifetime = 604800; // 1 week
+
read_invitation_key();
return true;
int udp_fd = setup_vpn_in_socket((sockaddr_t *) aip->ai_addr);
- if(tcp_fd < 0) {
+ if(udp_fd < 0) {
close(tcp_fd);
continue;
}
/* 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", myname);
-
- execute_script("tinc-up", envp);
-
- for(int i = 0; i < 4; i++)
- free(envp[i]);
+ environment_t env;
+ environment_init(&env);
+ execute_script("tinc-up", &env);
+ environment_exit(&env);
}
void device_disable(void) {
- 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", myname);
-
- execute_script("tinc-down", envp);
-
- for(int i = 0; i < 4; i++)
- free(envp[i]);
+ environment_t env;
+ environment_init(&env);
+ execute_script("tinc-down", &env);
+ environment_exit(&env);
if (devops.disable)
devops.disable();
/* Generate packet encryption key */
if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher))
- cipher = xstrdup("blowfish");
+ cipher = xstrdup("aes-256-cbc");
if(!strcasecmp(cipher, "none")) {
myself->incipher = NULL;
}
if(!get_config_string(lookup_config(config_tree, "Digest"), &digest))
- digest = xstrdup("sha1");
+ digest = xstrdup("sha256");
if(!strcasecmp(digest, "none")) {
myself->indigest = NULL;
devops = raw_socket_devops;
else if(!strcasecmp(type, "multicast"))
devops = multicast_devops;
+ else if(!strcasecmp(type, "fd"))
+ devops = fd_devops;
#ifdef ENABLE_UML
else if(!strcasecmp(type, "uml"))
devops = uml_devops;
}
for(int i = 0; i < listen_sockets; i++) {
- salen = sizeof sa;
+ salen = sizeof(sa);
if(getsockname(i + 3, &sa.sa, &salen) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(sockerrno));
return false;
if(!port_specified || atoi(myport) == 0) {
sockaddr_t sa;
- socklen_t salen = sizeof sa;
+ socklen_t salen = sizeof(sa);
if(!getsockname(listen_socket[0].udp.fd, &sa.sa, &salen)) {
free(myport);
sockaddr2str(&sa, NULL, &myport);
exit_control();
- free(myname);
free(scriptextension);
free(scriptinterpreter);