From 9e57e7d29b3d6d25e6ad116e83d81ef059c7aedb Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 7 Feb 2024 18:22:54 +0800 Subject: [PATCH] fix: fix `lan-allowed-ips` does not take effect --- listener/http/server.go | 4 +++- listener/mixed/mixed.go | 4 +++- listener/socks/tcp.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/listener/http/server.go b/listener/http/server.go index 4ed597091..8fc9da596 100644 --- a/listener/http/server.go +++ b/listener/http/server.go @@ -36,7 +36,9 @@ func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener } func NewWithAuthenticate(addr string, tunnel C.Tunnel, authenticate bool, additions ...inbound.Addition) (*Listener, error) { + isDefault := false if len(additions) == 0 { + isDefault = true additions = []inbound.Addition{ inbound.WithInName("DEFAULT-HTTP"), inbound.WithSpecialRules(""), @@ -71,7 +73,7 @@ func NewWithAuthenticate(addr string, tunnel C.Tunnel, authenticate bool, additi t.SetKeepAlive(false) } } - if len(additions) == 2 { // only apply on default listener + if isDefault { // only apply on default listener if !inbound.IsRemoteAddrDisAllowed(conn.RemoteAddr()) { _ = conn.Close() continue diff --git a/listener/mixed/mixed.go b/listener/mixed/mixed.go index b645cbbbc..367b7a368 100644 --- a/listener/mixed/mixed.go +++ b/listener/mixed/mixed.go @@ -37,7 +37,9 @@ func (l *Listener) Close() error { } func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) { + isDefault := false if len(additions) == 0 { + isDefault = true additions = []inbound.Addition{ inbound.WithInName("DEFAULT-MIXED"), inbound.WithSpecialRules(""), @@ -62,7 +64,7 @@ func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener } continue } - if len(additions) == 2 { // only apply on default listener + if isDefault { // only apply on default listener if !inbound.IsRemoteAddrDisAllowed(c.RemoteAddr()) { _ = c.Close() continue diff --git a/listener/socks/tcp.go b/listener/socks/tcp.go index a33f190ea..b6ea023a8 100644 --- a/listener/socks/tcp.go +++ b/listener/socks/tcp.go @@ -35,7 +35,9 @@ func (l *Listener) Close() error { } func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) { + isDefault := false if len(additions) == 0 { + isDefault = true additions = []inbound.Addition{ inbound.WithInName("DEFAULT-SOCKS"), inbound.WithSpecialRules(""), @@ -59,7 +61,7 @@ func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener } continue } - if len(additions) == 2 { // only apply on default listener + if isDefault { // only apply on default listener if !inbound.IsRemoteAddrDisAllowed(c.RemoteAddr()) { _ = c.Close() continue