mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-24 10:02:16 -05:00
set IP_FREEBIND if available to bind to non-existent interfaces
This commit is contained in:
parent
5998c9ec1a
commit
67c34a7460
@ -10,6 +10,9 @@ vNEXT:
|
||||
actual errors if connections are dropped before
|
||||
getting to getpeername).
|
||||
|
||||
Set IP_FREEDBIND if available to bind to addresses
|
||||
that don't yet exist.
|
||||
|
||||
v1.15: 27JUL2013
|
||||
Added --transparent option for transparent proxying.
|
||||
See README for iptables magic and capability
|
||||
|
13
common.c
13
common.c
@ -62,7 +62,7 @@ int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list)
|
||||
{
|
||||
struct sockaddr_storage *saddr;
|
||||
struct addrinfo *addr;
|
||||
int i, res, reuse;
|
||||
int i, res, one;
|
||||
int num_addr = 0;
|
||||
|
||||
for (addr = addr_list; addr; addr = addr->ai_next)
|
||||
@ -83,9 +83,14 @@ int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list)
|
||||
(*sockfd)[i] = socket(saddr->ss_family, SOCK_STREAM, 0);
|
||||
check_res_dumpdie((*sockfd)[i], addr, "socket");
|
||||
|
||||
reuse = 1;
|
||||
res = setsockopt((*sockfd)[i], SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse));
|
||||
check_res_dumpdie(res, addr, "setsockopt");
|
||||
one = 1;
|
||||
res = setsockopt((*sockfd)[i], SOL_SOCKET, SO_REUSEADDR, (char*)&one, sizeof(one));
|
||||
check_res_dumpdie(res, addr, "setsockopt(SO_REUSEADDR)");
|
||||
|
||||
if (IP_FREEBIND) {
|
||||
res = setsockopt((*sockfd)[i], IPPROTO_IP, IP_FREEBIND, (char*)&one, sizeof(one));
|
||||
check_res_dumpdie(res, addr, "setsockopt(IP_FREEBIND)");
|
||||
}
|
||||
|
||||
res = bind((*sockfd)[i], addr->ai_addr, addr->ai_addrlen);
|
||||
check_res_dumpdie(res, addr, "bind");
|
||||
|
Loading…
Reference in New Issue
Block a user