mirror of
https://github.com/net-byte/vtun
synced 2024-03-14 10:50:03 +08:00
add tls
This commit is contained in:
parent
e78f121448
commit
2f81fcef89
@ -12,6 +12,7 @@ A simple vpn.
|
||||
```
|
||||
Usage of ./vtun:
|
||||
-S server mode
|
||||
-t enable tls
|
||||
-c string
|
||||
tun interface CIDR (default "172.16.0.1/24")
|
||||
-k string
|
||||
|
@ -9,6 +9,7 @@ type Config struct {
|
||||
Key string
|
||||
Protocol string
|
||||
ServerMode bool
|
||||
TLS bool
|
||||
}
|
||||
|
||||
func (config *Config) Init() {
|
||||
|
@ -40,7 +40,11 @@ func DstAddr(b []byte) (addr string) {
|
||||
}
|
||||
|
||||
func ConnectWS(config config.Config) *websocket.Conn {
|
||||
u := url.URL{Scheme: "wss", Host: config.ServerAddr, Path: "/way-to-freedom"}
|
||||
scheme := "ws"
|
||||
if config.TLS {
|
||||
scheme = "wss"
|
||||
}
|
||||
u := url.URL{Scheme: scheme, Host: config.ServerAddr, Path: "/way-to-freedom"}
|
||||
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")
|
||||
c, _, err := websocket.DefaultDialer.Dial(u.String(), header)
|
||||
|
1
main.go
1
main.go
@ -16,6 +16,7 @@ func main() {
|
||||
flag.StringVar(&config.Key, "k", "6w9z$C&F)J@NcRfWjXn3r4u7x!A%D*G-", "encryption key")
|
||||
flag.StringVar(&config.Protocol, "p", "udp", "protocol udp/ws")
|
||||
flag.BoolVar(&config.ServerMode, "S", false, "server mode")
|
||||
flag.BoolVar(&config.TLS, "t", false, "enable tls")
|
||||
flag.Parse()
|
||||
|
||||
switch config.Protocol {
|
||||
|
Loading…
Reference in New Issue
Block a user