diff --git a/README.md b/README.md index 3e47d54..89d6489 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ Usage of ./vtun: server address (default ":3001") -d string dns address (default "8.8.8.8:53") + -path string + websocket path (default "/way-to-freedom") -P enable pporf server on :6060 -S server mode -g client global mode diff --git a/common/config/config.go b/common/config/config.go index 7be515f..01b93c4 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -8,16 +8,17 @@ import ( ) type Config struct { - LocalAddr string - ServerAddr string - CIDR string - Key string - Protocol string - DNS string - ServerMode bool - GlobalMode bool - Obfuscate bool - Pprof bool + LocalAddr string + ServerAddr string + CIDR string + Key string + Protocol string + DNS string + WebSocketPath string + ServerMode bool + GlobalMode bool + Obfuscate bool + Pprof bool } func (config *Config) Init() { diff --git a/common/netutil/netutil.go b/common/netutil/netutil.go index f44f675..a2b4e7c 100644 --- a/common/netutil/netutil.go +++ b/common/netutil/netutil.go @@ -51,7 +51,7 @@ func ConnectServer(config config.Config) net.Conn { if config.Protocol == "wss" { scheme = "wss" } - u := url.URL{Scheme: scheme, Host: config.ServerAddr, Path: "/way-to-freedom"} + u := url.URL{Scheme: scheme, Host: config.ServerAddr, Path: config.WebSocketPath} header := make(http.Header) header.Set("user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36") header.Set("key", config.Key) diff --git a/main.go b/main.go index f34a3a0..d4eb551 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ func main() { flag.StringVar(&config.Key, "k", "6w9z$C&F)J@NcRfWjXn3r4u7x!A%D*G-", "key") flag.StringVar(&config.Protocol, "p", "wss", "protocol tcp/udp/ws/wss") flag.StringVar(&config.DNS, "d", "8.8.8.8:53", "dns address") + flag.StringVar(&config.WebSocketPath, "path", "/way-to-freedom", "websocket path") flag.BoolVar(&config.ServerMode, "S", false, "server mode") flag.BoolVar(&config.GlobalMode, "g", false, "client global mode") flag.BoolVar(&config.Obfuscate, "obfs", false, "enable obfuscation") diff --git a/ws/wsserver.go b/ws/wsserver.go index 6349d9b..e1b5136 100644 --- a/ws/wsserver.go +++ b/ws/wsserver.go @@ -31,7 +31,7 @@ func StartServer(config config.Config) { // server -> client go toClient(config, iface, c) // client -> server - http.HandleFunc("/way-to-freedom", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc(config.WebSocketPath, func(w http.ResponseWriter, r *http.Request) { if !checkPermission(w, r, config) { return }