projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Wipe (some) secrets from memory after use
[tinc]
/
src
/
net.c
diff --git
a/src/net.c
b/src/net.c
index
78d4b76
..
9669bc9
100644
(file)
--- a/
src/net.c
+++ b/
src/net.c
@@
-26,6
+26,7
@@
#include "conf_net.h"
#include "conf.h"
#include "connection.h"
#include "conf_net.h"
#include "conf.h"
#include "connection.h"
+#include "crypto.h"
#include "graph.h"
#include "logger.h"
#include "meta.h"
#include "graph.h"
#include "logger.h"
#include "meta.h"
@@
-54,7
+55,7
@@
void purge(void) {
if(!n->status.reachable) {
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Purging node %s (%s)", n->name, n->hostname);
if(!n->status.reachable) {
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Purging node %s (%s)", n->name, n->hostname);
- for splay_each(subnet_t, s, n->subnet_tree) {
+ for splay_each(subnet_t, s,
&
n->subnet_tree) {
send_del_subnet(everyone, s);
if(!strictsubnets) {
send_del_subnet(everyone, s);
if(!strictsubnets) {
@@
-62,7
+63,7
@@
void purge(void) {
}
}
}
}
- for splay_each(edge_t, e, n->edge_tree) {
+ for splay_each(edge_t, e,
&
n->edge_tree) {
if(!tunnelserver) {
send_del_edge(everyone, e);
}
if(!tunnelserver) {
send_del_edge(everyone, e);
}
@@
-81,7
+82,7
@@
void purge(void) {
return;
}
return;
}
- if(!autoconnect && (!strictsubnets || !n->subnet_tree
->
head))
+ if(!autoconnect && (!strictsubnets || !n->subnet_tree
.
head))
/* in strictsubnets mode do not delete nodes with subnets */
{
node_del(n);
/* in strictsubnets mode do not delete nodes with subnets */
{
node_del(n);
@@
-159,7
+160,7
@@
void terminate_connection(connection_t *c, bool report) {
do_outgoing_connection(outgoing);
}
do_outgoing_connection(outgoing);
}
-#ifndef HAVE_
MINGW
+#ifndef HAVE_
WINDOWS
/* Clean up dead proxy processes */
while(waitpid(-1, NULL, WNOHANG) > 0);
/* Clean up dead proxy processes */
while(waitpid(-1, NULL, WNOHANG) > 0);
@@
-256,7
+257,7
@@
static void timeout_handler(void *data) {
}
timeout_set(data, &(struct timeval) {
}
timeout_set(data, &(struct timeval) {
- 1,
rand() % 100000
+ 1,
jitter()
});
}
});
}
@@
-268,9
+269,7
@@
static void periodic_handler(void *data) {
if(contradicting_del_edge > 100 && contradicting_add_edge > 100) {
logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime);
if(contradicting_del_edge > 100 && contradicting_add_edge > 100) {
logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime);
- nanosleep(&(struct timespec) {
- sleeptime, 0
- }, NULL);
+ sleep_millis(sleeptime * 1000);
sleeptime *= 2;
if(sleeptime < 0) {
sleeptime *= 2;
if(sleeptime < 0) {
@@
-294,7
+293,7
@@
static void periodic_handler(void *data) {
}
timeout_set(data, &(struct timeval) {
}
timeout_set(data, &(struct timeval) {
- 5,
rand() % 100000
+ 5,
jitter()
});
}
});
}
@@
-309,7
+308,7
@@
void handle_meta_connection_data(connection_t *c) {
}
}
}
}
-#ifndef HAVE_
MINGW
+#ifndef HAVE_
WINDOWS
static void sigterm_handler(void *data) {
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
event_exit();
static void sigterm_handler(void *data) {
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
event_exit();
@@
-391,7
+390,7
@@
int reload_configuration(void) {
}
}
} else { /* Only read our own subnets back in */
}
}
} else { /* Only read our own subnets back in */
- for splay_each(subnet_t, subnet, myself->subnet_tree)
+ for splay_each(subnet_t, subnet,
&
myself->subnet_tree)
if(!subnet->expires) {
subnet->expires = 1;
}
if(!subnet->expires) {
subnet->expires = 1;
}
@@
-418,7
+417,7
@@
int reload_configuration(void) {
cfg = lookup_config_next(&config_tree, cfg);
}
cfg = lookup_config_next(&config_tree, cfg);
}
- for splay_each(subnet_t, subnet, myself->subnet_tree) {
+ for splay_each(subnet_t, subnet,
&
myself->subnet_tree) {
if(subnet->expires == 1) {
send_del_subnet(everyone, subnet);
subnet_update(myself, subnet, false);
if(subnet->expires == 1) {
send_del_subnet(everyone, subnet);
subnet_update(myself, subnet, false);
@@
-482,13
+481,13
@@
void retry(void) {
int main_loop(void) {
last_periodic_run_time = now;
timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval) {
int main_loop(void) {
last_periodic_run_time = now;
timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval) {
- pingtimeout,
rand() % 100000
+ pingtimeout,
jitter()
});
timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval) {
0, 0
});
});
timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval) {
0, 0
});
-#ifndef HAVE_
MINGW
+#ifndef HAVE_
WINDOWS
signal_t sighup = {0};
signal_t sigterm = {0};
signal_t sigquit = {0};
signal_t sighup = {0};
signal_t sigterm = {0};
signal_t sigquit = {0};
@@
-507,7
+506,7
@@
int main_loop(void) {
return 1;
}
return 1;
}
-#ifndef HAVE_
MINGW
+#ifndef HAVE_
WINDOWS
signal_del(&sighup);
signal_del(&sigterm);
signal_del(&sigquit);
signal_del(&sighup);
signal_del(&sigterm);
signal_del(&sigquit);