mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-28 03:52:21 -05:00
#ifdef IP_BINDANY/IPV6_BINDANY cases
This commit is contained in:
parent
0d8e2438de
commit
ece6e28e45
7
common.c
7
common.c
@ -120,13 +120,20 @@ int bind_peer(int fd, int fd_from)
|
|||||||
* got here */
|
* got here */
|
||||||
res = getpeername(fd_from, from.ai_addr, &from.ai_addrlen);
|
res = getpeername(fd_from, from.ai_addr, &from.ai_addrlen);
|
||||||
CHECK_RES_RETURN(res, "getpeername");
|
CHECK_RES_RETURN(res, "getpeername");
|
||||||
|
#ifndef IP_BINDANY /* use IP_TRANSPARENT */
|
||||||
|
res = setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &trans, sizeof(trans));
|
||||||
|
CHECK_RES_DIE(res, "setsockopt");
|
||||||
|
#else
|
||||||
if (from.ai_addr->sa_family==AF_INET) { /* IPv4 */
|
if (from.ai_addr->sa_family==AF_INET) { /* IPv4 */
|
||||||
res = setsockopt(fd, IPPROTO_IP, IP_BINDANY, &trans, sizeof(trans));
|
res = setsockopt(fd, IPPROTO_IP, IP_BINDANY, &trans, sizeof(trans));
|
||||||
CHECK_RES_RETURN(res, "setsockopt IP_BINDANY");
|
CHECK_RES_RETURN(res, "setsockopt IP_BINDANY");
|
||||||
|
#ifdef IPV6_BINDANY
|
||||||
} else { /* IPv6 */
|
} else { /* IPv6 */
|
||||||
res = setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &trans, sizeof(trans));
|
res = setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &trans, sizeof(trans));
|
||||||
CHECK_RES_RETURN(res, "setsockopt IPV6_BINDANY");
|
CHECK_RES_RETURN(res, "setsockopt IPV6_BINDANY");
|
||||||
|
#endif /* IPV6_BINDANY */
|
||||||
}
|
}
|
||||||
|
#endif /* IP_TRANSPARENT / IP_BINDANY */
|
||||||
res = bind(fd, from.ai_addr, from.ai_addrlen);
|
res = bind(fd, from.ai_addr, from.ai_addrlen);
|
||||||
CHECK_RES_RETURN(res, "bind");
|
CHECK_RES_RETURN(res, "bind");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user