This commit is contained in:
Alex Tsai 2022-02-16 21:20:26 +08:00
parent 0dafbc8b98
commit fe522af42b
5 changed files with 16 additions and 12 deletions

View File

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

View File

@ -14,6 +14,7 @@ type Config struct {
Key string
Protocol string
DNS string
WebSocketPath string
ServerMode bool
GlobalMode bool
Obfuscate bool

View File

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

View File

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

View File

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