Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vmess/vless): support network h2 #229

Merged
merged 4 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions component/outbound/dialer/v2ray/v2ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/mzz2017/softwind/protocol/http"
"github.com/mzz2017/softwind/transport/grpc"
)

Expand Down Expand Up @@ -141,6 +142,33 @@ func (s *V2Ray) Dialer(option *dialer.GlobalOption, iOption dialer.InstanceOptio
ServerName: sni,
AllowInsecure: s.AllowInsecure,
}
case "http", "http2", "h2":
sni := s.SNI
if sni == "" {
sni = s.Add
}
scheme := "http"
if s.TLS == "tls" {
scheme = "https"
}
u := url.URL{
Scheme: scheme,
Host: net.JoinHostPort(s.Add, s.Port),
Path: s.Path,
RawQuery: url.Values{
"sni": []string{sni},
"allowInsecure": []string{common.BoolToString(s.AllowInsecure)},
"tlsImplementation": []string{option.TlsImplementation},
"utlsImitate": []string{option.UtlsImitate},
"host": []string{s.Host},
"alpn": []string{s.Alpn},
"transport": []string{"1"},
}.Encode(),
}
d, err = http.NewHTTPProxy(&u, direct.SymmetricDirect)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("%w: network: %v", dialer.UnexpectedFieldErr, s.Net)
}
Expand Down
1 change: 1 addition & 0 deletions docs/en/proxy-protocols.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [x] WS
- [x] TLS
- [x] gRPC
- [x] h2
- [x] Shadowsocks
- [x] AEAD Ciphers
- [x] Stream Ciphers
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/json-iterator/go v1.1.12
github.com/miekg/dns v1.1.55
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/mzz2017/softwind v0.0.0-20230710175107-0107af8a1d26
github.com/mzz2017/softwind v0.0.0-20230722080658-973f985df174
github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd
github.com/safchain/ethtool v0.3.0
github.com/sirupsen/logrus v1.9.3
Expand All @@ -24,6 +24,7 @@ require (
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
golang.org/x/sys v0.10.0
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

require (
Expand All @@ -41,7 +42,6 @@ require (
golang.org/x/net v0.12.0 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/mzz2017/disk-bloom v1.0.1 h1:rEF9MiXd9qMW3ibRpqcerLXULoTgRlM21yqqJl1B
github.com/mzz2017/disk-bloom v1.0.1/go.mod h1:JLHETtUu44Z6iBmsqzkOtFlRvXSlKnxjwiBRDapizDI=
github.com/mzz2017/quic-go v0.0.0-20230706143320-cc858d4932b7 h1:9zmZilN02x3byMB2X3x+B4iyKHkucv70WA4hsyZkjo8=
github.com/mzz2017/quic-go v0.0.0-20230706143320-cc858d4932b7/go.mod h1:3H6d55CEofIWWr3gQThiB27+hA3WG5tATtPovzEYPAA=
github.com/mzz2017/softwind v0.0.0-20230710175107-0107af8a1d26 h1:kVjALMAhr+rYw77TfrpD8VNIRbZ2/2pN1AYWBcL6eqM=
github.com/mzz2017/softwind v0.0.0-20230710175107-0107af8a1d26/go.mod h1:Fz8fgR7/dbnfR6RLpeOMkUDyebq4xShdmjj+cE5jnJ4=
github.com/mzz2017/softwind v0.0.0-20230722080658-973f985df174 h1:I4JKJSOCxUtFgiMB5VpoqdC70tncD1UkKd2Qvi5/A0o=
github.com/mzz2017/softwind v0.0.0-20230722080658-973f985df174/go.mod h1:Fz8fgR7/dbnfR6RLpeOMkUDyebq4xShdmjj+cE5jnJ4=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down