}
}
+/* Put a misbehaving connection in the tarpit */
+void tarpit(int fd) {
+ static int pits[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ static unsigned int next_pit = 0;
+
+ if(pits[next_pit] != -1) {
+ closesocket(pits[next_pit]);
+ }
+
+ pits[next_pit++] = fd;
+
+ if(next_pit >= sizeof pits / sizeof pits[0]) {
+ next_pit = 0;
+ }
+}
+
/*
Terminate a connection:
- Mark it as inactive
logger(DEBUG_CONNECTIONS, LOG_WARNING, "Timeout while connecting to %s (%s)", c->name, c->hostname);
} else {
logger(DEBUG_CONNECTIONS, LOG_WARNING, "Timeout from %s (%s) during authentication", c->name, c->hostname);
+ c->status.tarpit = true;
}
terminate_connection(c, c->edge);
void handle_meta_connection_data(connection_t *c) {
if(!receive_meta(c)) {
+ if(!c->status.control) {
+ c->status.tarpit = true;
+ }
+
terminate_connection(c, c->edge);
return;
}
read_config_options(config_tree, NULL);
snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, myself->name);
- read_config_file(config_tree, fname);
+ read_config_file(config_tree, fname, true);
/* Parse some options that are allowed to be changed while tinc is running */