Feature: add websocket headers support in vmess

This commit is contained in:
Dreamacro
2018-12-11 00:25:05 +08:00
parent 34c8655974
commit 1607d3253f
5 changed files with 118 additions and 34 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net"
"net/http"
"net/url"
"strings"
"time"
@ -21,6 +22,7 @@ type websocketConn struct {
type websocketConfig struct {
host string
path string
headers map[string]string
tls bool
tlsConfig *tls.Config
}
@ -127,7 +129,14 @@ func newWebsocketConn(conn net.Conn, c *websocketConfig) (net.Conn, error) {
Path: c.path,
}
wsConn, resp, err := dialer.Dial(uri.String(), nil)
headers := http.Header{}
if c.headers != nil {
for k, v := range c.headers {
headers.Set(k, v)
}
}
wsConn, resp, err := dialer.Dial(uri.String(), headers)
if err != nil {
var reason string
if resp != nil {