From e564d9ef7eb93315f6236cc75d1022dd6a580450 Mon Sep 17 00:00:00 2001 From: Jim Han <50871214+JimhHan@users.noreply.github.com> Date: Mon, 29 Mar 2021 00:16:07 +0800 Subject: [PATCH] Fix: TCP & WS override AcceptProxyProtocol (#425) --- transport/internet/tcp/hub.go | 3 ++- transport/internet/websocket/hub.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/transport/internet/tcp/hub.go b/transport/internet/tcp/hub.go index 2c95cb99..02042c3c 100644 --- a/transport/internet/tcp/hub.go +++ b/transport/internet/tcp/hub.go @@ -38,7 +38,8 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe if streamSettings.SocketSettings == nil { streamSettings.SocketSettings = &internet.SocketConfig{} } - streamSettings.SocketSettings.AcceptProxyProtocol = l.config.AcceptProxyProtocol + streamSettings.SocketSettings.AcceptProxyProtocol = + l.config.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol } var listener net.Listener var err error diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index c1848345..06ca2d28 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -89,7 +89,8 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet if streamSettings.SocketSettings == nil { streamSettings.SocketSettings = &internet.SocketConfig{} } - streamSettings.SocketSettings.AcceptProxyProtocol = l.config.AcceptProxyProtocol + streamSettings.SocketSettings.AcceptProxyProtocol = + l.config.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol } var listener net.Listener var err error