summaryrefslogtreecommitdiff
path: root/src/core/socket.h
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@users.noreply.github.com>2016-08-02 23:18:23 +0530
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-08-02 13:48:23 -0400
commit9d565427647a874b7eda64ef0cb41ea74a96659b (patch)
tree0dc7f6b19040c1d6fbec0612cd9732e4fc83ffa0 /src/core/socket.h
parent87edd2b116c107b54c844e88de06be62ab55e29d (diff)
socket: add support to control no. of connections from one source (#3607)
Introduce MaxConnectionsPerSource= that is number of concurrent connections allowed per IP. RFE: 1939
Diffstat (limited to 'src/core/socket.h')
-rw-r--r--src/core/socket.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/socket.h b/src/core/socket.h
index 6c32d67bef..2fe38ef2aa 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -20,6 +20,7 @@
***/
typedef struct Socket Socket;
+typedef struct SocketPeer SocketPeer;
#include "mount.h"
#include "service.h"
@@ -79,9 +80,12 @@ struct Socket {
LIST_HEAD(SocketPort, ports);
+ Hashmap *peers_by_address;
+
unsigned n_accepted;
unsigned n_connections;
unsigned max_connections;
+ unsigned max_connections_per_source;
unsigned backlog;
unsigned keep_alive_cnt;
@@ -164,6 +168,18 @@ struct Socket {
RateLimit trigger_limit;
};
+struct SocketPeer {
+ unsigned n_ref;
+
+ Socket *socket;
+ union sockaddr_union peer;
+};
+
+SocketPeer *socket_peer_ref(SocketPeer *p);
+SocketPeer *socket_peer_unref(SocketPeer *p);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(SocketPeer*, socket_peer_unref);
+
/* Called from the service code when collecting fds */
int socket_collect_fds(Socket *s, int **fds);