mirror of
https://github.com/yrutschle/sslh.git
synced 2025-06-06 10:23:14 +03:00
added TFO for listening socket
This commit is contained in:
parent
b0c3c8fdbc
commit
4e725e1520
21
common.c
21
common.c
@ -86,6 +86,24 @@ int get_fd_sockets(int *sockfd[])
|
|||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set TCP_FASTOPEN on listening socket if all client protocols support it */
|
||||||
|
int make_listen_tfo(int s)
|
||||||
|
{
|
||||||
|
int i, qlen = 5;
|
||||||
|
|
||||||
|
/* Don't do it if not supported */
|
||||||
|
if (!TCP_FASTOPEN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Don't do it if any protocol does not specify it */
|
||||||
|
for (i = 0; i < cfg.protocols_len; i++) {
|
||||||
|
if (! cfg.protocols[i].tfo_ok)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return setsockopt(s, SOL_SOCKET, TCP_FASTOPEN, (char*)&qlen, sizeof(qlen));
|
||||||
|
}
|
||||||
|
|
||||||
/* Starts listening sockets on specified addresses.
|
/* Starts listening sockets on specified addresses.
|
||||||
* IN: addr[], num_addr
|
* IN: addr[], num_addr
|
||||||
* OUT: *sockfd[] pointer to newly-allocated array of file descriptors
|
* OUT: *sockfd[] pointer to newly-allocated array of file descriptors
|
||||||
@ -134,6 +152,9 @@ int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list)
|
|||||||
res = setsockopt((*sockfd)[i], SOL_SOCKET, SO_REUSEADDR, (char*)&one, sizeof(one));
|
res = setsockopt((*sockfd)[i], SOL_SOCKET, SO_REUSEADDR, (char*)&one, sizeof(one));
|
||||||
check_res_dump(CR_DIE, res, addr, "setsockopt(SO_REUSEADDR)");
|
check_res_dump(CR_DIE, res, addr, "setsockopt(SO_REUSEADDR)");
|
||||||
|
|
||||||
|
res = make_listen_tfo((*sockfd)[i]);
|
||||||
|
check_res_dump(CR_WARN, res, addr, "setsockopt(TCP_FASTOPEN)");
|
||||||
|
|
||||||
if (addr->ai_flags & SO_KEEPALIVE) {
|
if (addr->ai_flags & SO_KEEPALIVE) {
|
||||||
res = setsockopt((*sockfd)[i], SOL_SOCKET, SO_KEEPALIVE, (char*)&one, sizeof(one));
|
res = setsockopt((*sockfd)[i], SOL_SOCKET, SO_KEEPALIVE, (char*)&one, sizeof(one));
|
||||||
check_res_dump(CR_DIE, res, addr, "setsockopt(SO_KEEPALIVE)");
|
check_res_dump(CR_DIE, res, addr, "setsockopt(SO_KEEPALIVE)");
|
||||||
|
4
common.h
4
common.h
@ -67,6 +67,10 @@
|
|||||||
#define IP_FREEBIND 0
|
#define IP_FREEBIND 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TCP_FASTOPEN
|
||||||
|
#define TCP_FASTOPEN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TCP_FASTOPEN_CONNECT
|
#ifndef TCP_FASTOPEN_CONNECT
|
||||||
#define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect. */
|
#define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect. */
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user