X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_socket.c;h=a69612790852b2d7379ae8d781360c6722a852c6;hp=2da6253ee3a3dc6c8d62dd669629ce1fbcc90c8d;hb=d6b45d005530496e48325a6174ecdd889a17bfc1;hpb=7ee885a1f6776be85e5397eda04f75d98ff0b631 diff --git a/src/net_socket.c b/src/net_socket.c index 2da6253e..a6961279 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -1,7 +1,7 @@ /* net_socket.c -- Handle various kinds of sockets. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2018 Guus Sliepen 2006 Scott Lamb 2009 Florian Forster @@ -41,7 +41,7 @@ int maxtimeout = 900; int seconds_till_retry = 5; int udp_rcvbuf = 1024 * 1024; int udp_sndbuf = 1024 * 1024; -int max_connection_burst = 100; +int max_connection_burst = 10; int fwmark; listen_socket_t listen_socket[MAXSOCKETS]; @@ -122,6 +122,7 @@ static bool bind_to_interface(int sd) { } #else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */ + (void)sd; logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "BindToInterface"); #endif @@ -210,6 +211,7 @@ int setup_listen_socket(const sockaddr_t *sa) { memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); + ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr))) { closesocket(nfd); @@ -386,7 +388,7 @@ void finish_connecting(connection_t *c) { send_id(c); } -static void do_outgoing_pipe(connection_t *c, char *command) { +static void do_outgoing_pipe(connection_t *c, const char *command) { #ifndef HAVE_MINGW int fd[2]; @@ -434,6 +436,8 @@ static void do_outgoing_pipe(connection_t *c, char *command) { exit(result); #else + (void)c; + (void)command; logger(DEBUG_ALWAYS, LOG_ERR, "Proxy type exec not supported on this platform!"); return; #endif @@ -623,6 +627,7 @@ begin: } void setup_outgoing_connection(outgoing_t *outgoing, bool verbose) { + (void)verbose; timeout_del(&outgoing->ev); node_t *n = outgoing->node; @@ -654,6 +659,7 @@ remove: new connection */ void handle_new_meta_connection(void *data, int flags) { + (void)flags; listen_socket_t *l = data; connection_t *c; sockaddr_t sa; @@ -672,12 +678,6 @@ void handle_new_meta_connection(void *data, int flags) { // Check if we get many connections from the same host static sockaddr_t prev_sa; - static int tarpit = -1; - - if(tarpit >= 0) { - closesocket(tarpit); - tarpit = -1; - } if(!sockaddrcmp_noport(&sa, &prev_sa)) { static int samehost_burst; @@ -693,7 +693,7 @@ void handle_new_meta_connection(void *data, int flags) { samehost_burst++; if(samehost_burst > max_connection_burst) { - tarpit = fd; + tarpit(fd); return; } } @@ -716,7 +716,7 @@ void handle_new_meta_connection(void *data, int flags) { if(connection_burst >= max_connection_burst) { connection_burst = max_connection_burst; - tarpit = fd; + tarpit(fd); return; } @@ -745,7 +745,6 @@ void handle_new_meta_connection(void *data, int flags) { connection_add(c); c->allow_request = ID; - send_id(c); } #ifndef HAVE_MINGW @@ -753,6 +752,7 @@ void handle_new_meta_connection(void *data, int flags) { accept a new UNIX socket connection */ void handle_new_unix_connection(void *data, int flags) { + (void)flags; io_t *io = data; connection_t *c; sockaddr_t sa; @@ -782,8 +782,6 @@ void handle_new_unix_connection(void *data, int flags) { connection_add(c); c->allow_request = ID; - - send_id(c); } #endif