From 51eb50d9818bde0deaed8701b6af6043601e5b62 Mon Sep 17 00:00:00 2001 From: uoosef Date: Sun, 10 Sep 2023 21:42:07 +0330 Subject: [PATCH] implement session --- config/config.go | 1 + server/server.go | 2 ++ utils/helper.go | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 12985b9..43cc853 100644 --- a/config/config.go +++ b/config/config.go @@ -28,6 +28,7 @@ type Config struct { DelayBetweenChunks [2]int `mapstructure:"DelayBetweenChunks"` Hosts []resolve.Hosts `mapstructure:"Hosts"` ResolveSystem string `mapstructure:"-"` + UserSession string `mapstructure:"-"` } var G *Config diff --git a/server/server.go b/server/server.go index f03d930..82607dd 100644 --- a/server/server.go +++ b/server/server.go @@ -12,6 +12,7 @@ import ( "context" "fmt" "io" + "math/rand" "os" "os/signal" "strings" @@ -22,6 +23,7 @@ import ( var s5 *socks5.Server func Run(captureCTRLC bool) error { + config.G.UserSession = fmt.Sprintf("%08d", rand.Intn(1000)) appCache := utils.NewCache(time.Duration(config.G.DnsCacheTTL) * time.Second) var resolveSystem string diff --git a/utils/helper.go b/utils/helper.go index 6e2fd32..4d8f1bf 100644 --- a/utils/helper.go +++ b/utils/helper.go @@ -2,6 +2,7 @@ package utils import ( + "bepass/config" "fmt" "net" "net/url" @@ -22,6 +23,6 @@ func WSEndpointHelper(workerAddress, rawDestAddress, network string) (string, er if err != nil { return "", err } - endpoint := fmt.Sprintf("wss://%s/connect?host=%s&port=%s&net=%s", u.Host, dh, dp, network) + endpoint := fmt.Sprintf("wss://%s/connect?host=%s&port=%s&net=%s&session=%s", u.Host, dh, dp, network, config.G.UserSession) return endpoint, nil }