Skip to content

Commit

Permalink
Added httpupgrade network protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
lilendian0x00 committed Apr 4, 2024
1 parent bc830ad commit 713b9b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 6 additions & 1 deletion xray/trojan.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (t *Trojan) DetailsStr() string {

if copyV.Type == "" {

} else if copyV.Type == "http" || copyV.Type == "ws" || copyV.Type == "h2" {
} else if copyV.Type == "http" || copyV.Type == "httpupgrade" || copyV.Type == "ws" || copyV.Type == "h2" {
info += fmt.Sprintf("%s: %s\n%s: %s\n",
color.RedString("Host"), copyV.Host,
color.RedString("Path"), copyV.Path)
Expand Down Expand Up @@ -212,6 +212,11 @@ func (t *Trojan) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDe
s.HTTPSettings.Host = &h
}
break
case "httpupgrade":
s.HTTPUPGRADESettings = &conf.HttpUpgradeConfig{
Host: t.Host,
Path: t.Path,
}
case "grpc":
if len(t.ServiceName) > 0 {
if t.ServiceName[0] == '/' {
Expand Down
13 changes: 12 additions & 1 deletion xray/vless.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (v *Vless) DetailsStr() string {
color.RedString("Flow"), copyV.Flow)
if copyV.Type == "" {

} else if copyV.HeaderType == "http" || copyV.Type == "ws" || copyV.Type == "h2" {
} else if copyV.HeaderType == "http" || copyV.Type == "httpupgrade" || copyV.Type == "ws" || copyV.Type == "h2" {
info += fmt.Sprintf("%s: %s\n%s: %s\n",
color.RedString("Host"), copyV.Host,
color.RedString("Path"), copyV.Path)
Expand Down Expand Up @@ -198,16 +198,19 @@ func (v *Vless) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDet
}
`, string(pathb), string(hostb))))
}
break
case "kcp":
s.KCPSettings = &conf.KCPConfig{}
s.KCPSettings.HeaderConfig = json.RawMessage([]byte(fmt.Sprintf(`{ "type": "%s" }`, v.Type)))
break
case "ws":
s.WSSettings = &conf.WebSocketConfig{}
s.WSSettings.Path = v.Path
s.WSSettings.Headers = map[string]string{
"Host": v.Host,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36",
}
break
case "h2", "http":
s.HTTPSettings = &conf.HTTPConfig{
Path: v.Path,
Expand All @@ -216,6 +219,13 @@ func (v *Vless) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDet
h := conf.StringList(strings.Split(v.Host, ","))
s.HTTPSettings.Host = &h
}
break
case "httpupgrade":
s.HTTPUPGRADESettings = &conf.HttpUpgradeConfig{
Host: v.Host,
Path: v.Path,
}
break
case "grpc":
if len(v.ServiceName) > 0 {
if v.ServiceName[0] == '/' {
Expand All @@ -239,6 +249,7 @@ func (v *Vless) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDet
s.GRPCConfig.MultiMode = true
}
v.Flow = ""
break
}

if v.Security == "tls" {
Expand Down
8 changes: 7 additions & 1 deletion xray/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func method1(v *Vmess, link string) error {
return err
}

fmt.Println(string(decoded))
return nil
}

Expand Down Expand Up @@ -129,7 +130,7 @@ func (v *Vmess) DetailsStr() string {

if copyV.Network == "" {

} else if copyV.Type == "http" || copyV.Network == "ws" || copyV.Network == "h2" {
} else if copyV.Type == "http" || copyV.Network == "httpupgrade" || copyV.Network == "ws" || copyV.Network == "h2" {
if copyV.Type == "" {
copyV.Type = "none"
}
Expand Down Expand Up @@ -252,6 +253,11 @@ func (v *Vmess) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDet
h := conf.StringList(strings.Split(v.Host, ","))
s.HTTPSettings.Host = &h
}
case "httpupgrade":
s.HTTPUPGRADESettings = &conf.HttpUpgradeConfig{
Host: v.Host,
Path: v.Path,
}
case "grpc":
if len(v.Path) > 0 {
if v.Path[0] == '/' {
Expand Down

0 comments on commit 713b9b5

Please sign in to comment.