From 40c9829328d5c3e031541038f7b7817559dc841d Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Fri, 26 Jul 2024 10:55:03 +0800 Subject: [PATCH] fix: auth with CFMA compile issue --- listener/http/server.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/listener/http/server.go b/listener/http/server.go index 9b2797da1..77e10f084 100644 --- a/listener/http/server.go +++ b/listener/http/server.go @@ -33,10 +33,20 @@ func (l *Listener) Close() error { } func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) { - return NewWithAuthenticate(addr, tunnel, authStore.Authenticator(), additions...) + return NewWithAuthenticator(addr, tunnel, authStore.Authenticator(), additions...) } -func NewWithAuthenticate(addr string, tunnel C.Tunnel, authenticator auth.Authenticator, additions ...inbound.Addition) (*Listener, error) { +// NewWithAuthenticate +// never change type traits because it's used in CFMA +func NewWithAuthenticate(addr string, tunnel C.Tunnel, authenticate bool, additions ...inbound.Addition) (*Listener, error) { + authenticator := authStore.Authenticator() + if !authenticate { + authenticator = nil + } + return NewWithAuthenticator(addr, tunnel, authenticator, additions...) +} + +func NewWithAuthenticator(addr string, tunnel C.Tunnel, authenticator auth.Authenticator, additions ...inbound.Addition) (*Listener, error) { isDefault := false if len(additions) == 0 { isDefault = true