From 881ebfad5bfada3e2e5ad25d430ef771fca0f935 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Wed, 16 Oct 2024 20:48:07 +0800 Subject: [PATCH] add ClientAddr for websocket conn --- cmd/gost/config.go | 16 +++++++++++++--- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cmd/gost/config.go b/cmd/gost/config.go index 76a1e1f..dc6aca4 100644 --- a/cmd/gost/config.go +++ b/cmd/gost/config.go @@ -1,6 +1,7 @@ package main import ( + "github.com/go-gost/core/auth" "github.com/go-gost/core/logger" "github.com/go-gost/core/service" "github.com/go-gost/x/api" @@ -151,10 +152,19 @@ func buildService(cfg *config.Config) (services []service.Service) { } func buildAPIService(cfg *config.APIConfig) (service.Service, error) { - auther := auth_parser.ParseAutherFromAuth(cfg.Auth) - if cfg.Auther != "" { - auther = registry.AutherRegistry().Get(cfg.Auther) + var authers []auth.Authenticator + if auther := auth_parser.ParseAutherFromAuth(cfg.Auth); auther != nil { + authers = append(authers, auther) } + if cfg.Auther != "" { + authers = append(authers, registry.AutherRegistry().Get(cfg.Auther)) + } + + var auther auth.Authenticator + if len(authers) > 0 { + auther = auth.AuthenticatorGroup(authers...) + } + return api.NewService( cfg.Addr, api.PathPrefixOption(cfg.PathPrefix), diff --git a/go.mod b/go.mod index 0995c76..6d8c278 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.2 require ( github.com/go-gost/core v0.1.7 - github.com/go-gost/x v0.2.5 + github.com/go-gost/x v0.2.6 github.com/judwhite/go-svc v1.2.1 ) diff --git a/go.sum b/go.sum index 93f9b8e..c67edd9 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/go-gost/relay v0.5.0 h1:JG1tgy/KWiVXS0ukuVXvbM0kbYuJTWxYpJ5JwzsCf/c= github.com/go-gost/relay v0.5.0/go.mod h1:lcX+23LCQ3khIeASBo+tJ/WbwXFO32/N5YN6ucuYTG8= github.com/go-gost/tls-dissector v0.1.1 h1:2zUOTPzCQAUQ54Rpy0UEi3JPMQSYsIFSeFeKrzmkCoU= github.com/go-gost/tls-dissector v0.1.1/go.mod h1:/9QfdewqmHdaE362Hv5nDaSWLx3pCmtD870d6GaquXs= -github.com/go-gost/x v0.2.5 h1:G3V3BBFPLdEbFz2+yD4F/Y6o0gUq6LfNT+PQnYqFsb0= -github.com/go-gost/x v0.2.5/go.mod h1:X8T1VmysaCsmwBDI7ytFiAta1eRVZb4aj4XMg9dncjQ= +github.com/go-gost/x v0.2.6 h1:VPXx3vEW6LYfvhMqq7y4i4YVTos1K6l0KEYQdLZxKa0= +github.com/go-gost/x v0.2.6/go.mod h1:X8T1VmysaCsmwBDI7ytFiAta1eRVZb4aj4XMg9dncjQ= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=