mirror of https://github.com/F-Stack/f-stack.git
Nginx's stream also support transparent kernel network stack while set
`proxy_kernel_network_stack on`.
This commit is contained in:
parent
768e48cd48
commit
ff97268615
|
@ -349,10 +349,20 @@ failed:
|
||||||
|
|
||||||
#if (NGX_HAVE_TRANSPARENT_PROXY)
|
#if (NGX_HAVE_TRANSPARENT_PROXY)
|
||||||
|
|
||||||
|
#if (NGX_HAVE_FSTACK)
|
||||||
|
extern int is_fstack_fd(int sockfd);
|
||||||
|
#ifndef IP_BINDANY
|
||||||
|
#define IP_BINDANY 24
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, ngx_socket_t s)
|
ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, ngx_socket_t s)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
#if defined(NGX_HAVE_FSTACK)
|
||||||
|
int optname;
|
||||||
|
#endif
|
||||||
|
|
||||||
value = 1;
|
value = 1;
|
||||||
|
|
||||||
|
@ -377,12 +387,17 @@ ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, ngx_socket_t s)
|
||||||
FreeBSD define IP_BINDANY in freebsd/netinet/in.h
|
FreeBSD define IP_BINDANY in freebsd/netinet/in.h
|
||||||
Fstack should only support IP_BINDANY.
|
Fstack should only support IP_BINDANY.
|
||||||
****/
|
****/
|
||||||
#define IP_BINDANY 24
|
if(is_fstack_fd(s)){
|
||||||
if (setsockopt(s, IPPROTO_IP, IP_BINDANY,
|
optname = IP_BINDANY;
|
||||||
|
} else {
|
||||||
|
optname = IP_TRANSPARENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setsockopt(s, IPPROTO_IP, optname,
|
||||||
(const void *) &value, sizeof(int)) == -1)
|
(const void *) &value, sizeof(int)) == -1)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
|
||||||
"setsockopt(IP_BINDANY) failed");
|
"setsockopt(IP_BINDANY/IP_TRANSPARENT) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue