add ClientAddr for websocket conn

pull/616/head
ginuerzh 2024-10-16 20:48:07 +08:00
parent d5bb691b38
commit 881ebfad5b
3 changed files with 16 additions and 6 deletions

View File

@ -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),

2
go.mod
View File

@ -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
)

4
go.sum
View File

@ -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=