MINOR: tproxy: add support for OpenBSD
OpenBSD uses (SOL_SOCKET, SO_BINDANY) to enable transparent proxy on a socket. This patch adds support for the relevant setsockopt() calls.
This commit is contained in:
parent
ff30b6667b
commit
1eb7592bba
|
@ -96,6 +96,7 @@
|
|||
#if defined(IP_FREEBIND) \
|
||||
|| defined(IP_BINDANY) \
|
||||
|| defined(IPV6_BINDANY) \
|
||||
|| defined(SO_BINDANY) \
|
||||
|| defined(IP_TRANSPARENT) \
|
||||
|| defined(IPV6_TRANSPARENT)
|
||||
#define CONFIG_HAP_TRANSPARENT
|
||||
|
|
|
@ -332,6 +332,9 @@ void display_build_opts()
|
|||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
" IPV6_BINDANY"
|
||||
#endif
|
||||
#if defined(SO_BINDANY)
|
||||
" SO_BINDANY"
|
||||
#endif
|
||||
"\n");
|
||||
#endif
|
||||
|
|
|
@ -141,6 +141,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
|
|||
#endif
|
||||
#if defined(IP_BINDANY)
|
||||
|| (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
#if defined(SO_BINDANY)
|
||||
|| (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
)
|
||||
foreign_ok = 1;
|
||||
|
@ -156,6 +159,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
|
|||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
|| (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
#if defined(SO_BINDANY)
|
||||
|| (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
)
|
||||
foreign_ok = 1;
|
||||
|
@ -653,6 +659,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||
#endif
|
||||
#if defined(IP_BINDANY)
|
||||
&& (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
#if defined(SO_BINDANY)
|
||||
&& (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
) {
|
||||
msg = "cannot make listening socket transparent";
|
||||
|
@ -666,6 +675,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
&& (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
#if defined(SO_BINDANY)
|
||||
&& (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
) {
|
||||
msg = "cannot make listening socket transparent";
|
||||
|
|
Loading…
Reference in New Issue