Skip to content

Commit

Permalink
implement session
Browse files Browse the repository at this point in the history
  • Loading branch information
uoosef committed Sep 10, 2023
1 parent 0b579cc commit 51eb50d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"context"
"fmt"
"io"
"math/rand"
"os"
"os/signal"
"strings"
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package utils

import (
"bepass/config"
"fmt"
"net"
"net/url"
Expand All @@ -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
}

0 comments on commit 51eb50d

Please sign in to comment.