Skip to content

Commit

Permalink
fix: fix lan-allowed-ips does not take effect
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Feb 7, 2024
1 parent 20658f6 commit 9e57e7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion listener/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(""),
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion listener/mixed/mixed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(""),
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion listener/socks/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(""),
Expand All @@ -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
Expand Down

0 comments on commit 9e57e7d

Please sign in to comment.