mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-24 10:02:16 -05:00
#ifdef IP_BINDANY/IPV6_BINDANY cases
This commit is contained in:
parent
0d8e2438de
commit
ece6e28e45
13
common.c
13
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");
|
||||||
|
|
||||||
@ -160,7 +167,7 @@ int connect_addr(struct connection *cnx, int fd_from)
|
|||||||
sprintaddr(buf, sizeof(buf), a),
|
sprintaddr(buf, sizeof(buf), a),
|
||||||
a->ai_addr->sa_family, a->ai_addrlen);
|
a->ai_addr->sa_family, a->ai_addrlen);
|
||||||
|
|
||||||
/* XXX Needs to match ai_family from fd_from when being transparent! */
|
/* XXX Needs to match ai_family from fd_from when being transparent! */
|
||||||
fd = socket(a->ai_family, SOCK_STREAM, 0);
|
fd = socket(a->ai_family, SOCK_STREAM, 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
log_message(LOG_ERR, "forward to %s failed:socket: %s\n",
|
log_message(LOG_ERR, "forward to %s failed:socket: %s\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user