From 4456aaa4b5614a666f1e0ed80008a49148469449 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Fri, 15 Mar 2019 12:43:46 +1100 Subject: [PATCH] Feature: add custom headers support in v2ray-plugin (#137) --- adapters/outbound/shadowsocks.go | 13 +++++++------ component/v2ray-plugin/websocket.go | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/adapters/outbound/shadowsocks.go b/adapters/outbound/shadowsocks.go index b4d57c0c..62045997 100644 --- a/adapters/outbound/shadowsocks.go +++ b/adapters/outbound/shadowsocks.go @@ -48,11 +48,12 @@ type simpleObfsOption struct { } type v2rayObfsOption struct { - Mode string `obfs:"mode"` - Host string `obfs:"host,omitempty"` - Path string `obfs:"path,omitempty"` - TLS bool `obfs:"tls,omitempty"` - SkipCertVerify bool `obfs:"skip-cert-verify,omitempty"` + Mode string `obfs:"mode"` + Host string `obfs:"host,omitempty"` + Path string `obfs:"path,omitempty"` + TLS bool `obfs:"tls,omitempty"` + Headers map[string]string `obfs:"headers,omitempty"` + SkipCertVerify bool `obfs:"skip-cert-verify,omitempty"` } func (ss *ShadowSocks) Dial(metadata *C.Metadata) (net.Conn, error) { @@ -131,10 +132,10 @@ func NewShadowSocks(option ShadowSocksOption) (*ShadowSocks, error) { ClientSessionCache: getClientSessionCache(), } } - wsOption = &v2rayObfs.WebsocketOption{ Host: opts.Host, Path: opts.Path, + Headers: opts.Headers, TLSConfig: tlsConfig, } } diff --git a/component/v2ray-plugin/websocket.go b/component/v2ray-plugin/websocket.go index 03d6f854..1e53cb9b 100644 --- a/component/v2ray-plugin/websocket.go +++ b/component/v2ray-plugin/websocket.go @@ -11,6 +11,7 @@ import ( type WebsocketOption struct { Host string Path string + Headers map[string]string TLSConfig *tls.Config } @@ -20,6 +21,7 @@ func NewWebsocketObfs(conn net.Conn, option *WebsocketOption) (net.Conn, error) Host: option.Host, Path: option.Path, TLS: option.TLSConfig != nil, + Headers: option.Headers, TLSConfig: option.TLSConfig, }