Skip to content

Commit

Permalink
support tcp with http
Browse files Browse the repository at this point in the history
  • Loading branch information
xxf098 committed Apr 6, 2020
1 parent 9f7edc9 commit c21849c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
29 changes: 28 additions & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func createVmessOutboundDetourConfig(profile *Vmess) conf.OutboundDetourConfig {
Settings: &outboundsSettingsMsg1,
StreamSetting: &conf.StreamConfig{},
}
// TODO: type = "http"
if profile.Net == "ws" {
transportProtocol := conf.TransportProtocol(profile.Net)
vmessOutboundDetourConfig.StreamSetting = &conf.StreamConfig{
Expand Down Expand Up @@ -277,6 +276,34 @@ func createVmessOutboundDetourConfig(profile *Vmess) conf.OutboundDetourConfig {
}
}

// tcp带http伪装
if profile.Net == "tcp" && profile.Type == "http" {
transportProtocol := conf.TransportProtocol(profile.Net)
tcpSettingsHeader := v2ray.TCPSettingsHeader{
Type: profile.Type,
TCPSettingsRequest: v2ray.TCPSettingsRequest{
Version: "1.1",
Method: "GET",
Path: []string{profile.Path}, // TODO: split by ","
Headers: v2ray.HTTPHeaders{
UserAgent: []string{"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"},
AcceptEncoding: []string{"gzip, deflate"},
Connection: "keep-alive",
Pragma: "no-cache",
Host: []string{profile.Host}, // TODO: split by ","
},
},
}
header, _ := json.Marshal(tcpSettingsHeader)
vmessOutboundDetourConfig.StreamSetting = &conf.StreamConfig{
Network: &transportProtocol,
Security: profile.TLS,
TCPSettings: &conf.TCPConfig{
HeaderConfig: json.RawMessage(header),
},
}
}

if profile.TLS == "tls" {
vmessOutboundDetourConfig.StreamSetting.Security = profile.TLS
tlsConfig := &conf.TLSConfig{Insecure: true}
Expand Down
19 changes: 19 additions & 0 deletions v2ray/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ type QUICSettingsHeader struct {
type KCPSettingsHeader struct {
Type string `json:"type"`
}
type TCPSettingsHeader struct {
Type string `json:"type"`
TCPSettingsRequest TCPSettingsRequest `json:"request"`
}

type TCPSettingsRequest struct {
Version string `json:"version"`
Method string `json:"method"`
Path []string `json:"path"`
Headers HTTPHeaders `json:"headers"`
}

type HTTPHeaders struct {
UserAgent []string `json:"User-Agent"`
AcceptEncoding []string `json:"Accept-Encoding"`
Connection string `json:"Connection"`
Pragma string `json:"Pragma"`
Host []string `json:"Host"`
}

type TLSSettings struct {
AllowInsecure bool `json:"allowInsecure"`
Expand Down

0 comments on commit c21849c

Please sign in to comment.