mirror of
https://github.com/net-byte/vtun
synced 2024-03-14 10:50:03 +08:00
fix issue #8
This commit is contained in:
parent
0dafbc8b98
commit
fe522af42b
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
|
1
main.go
1
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")
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user