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

Implement support for the QUIC protocol and intelligent switching policy #37

Merged
merged 56 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3541d20
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
de89cdb
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
25224f9
try
DrakenLibra Sep 19, 2023
f7f4faa
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
86d2cfd
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
43e69e0
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
da463b7
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
2180d30
Try to add quic-go for GT
DrakenLibra Sep 19, 2023
8633e98
Try to add quic-go for GT. Remove additional workflow check.
DrakenLibra Sep 21, 2023
3a5e672
Try to add quic-go for GT.
DrakenLibra Sep 21, 2023
682bde6
Try to add quic-go for GT.
DrakenLibra Sep 21, 2023
aa66fec
Try to add quic-go for GT.
DrakenLibra Sep 21, 2023
e60931a
Try to add quic-go for GT.
DrakenLibra Sep 21, 2023
dddf2eb
Try to add quic-go for GT.
DrakenLibra Sep 21, 2023
9fa3d60
Try to add quic-go for GT.
DrakenLibra Sep 21, 2023
843143d
Add quic-go for GT successfully.
DrakenLibra Sep 24, 2023
71669a5
Add 'Internal QUIC Penetration' description for GT.
DrakenLibra Sep 24, 2023
a6ee6d0
Add 'QUIC test' for GT.
DrakenLibra Sep 24, 2023
ea107ef
Fix.
DrakenLibra Sep 24, 2023
a57e397
Fix.
DrakenLibra Sep 24, 2023
5e36287
Add QUIC support for GT.
DrakenLibra Sep 25, 2023
e44abff
Add QUIC support for GT.
DrakenLibra Sep 26, 2023
03ec09b
Add QUIC support for GT.
DrakenLibra Sep 26, 2023
6938a5c
Add intelligent switch support for GT.
DrakenLibra Sep 26, 2023
f28aeb6
Add intelligent switch support for GT.
DrakenLibra Sep 27, 2023
0681758
Add intelligent switch support for GT.
DrakenLibra Sep 27, 2023
c0431cc
Try quic bbr for GT.
DrakenLibra Sep 27, 2023
9476917
Try quic bbr for GT.
DrakenLibra Sep 27, 2023
9c2bf1e
Try quic bbr for GT.
DrakenLibra Sep 27, 2023
be2499a
Try quic bbr for GT.
DrakenLibra Sep 28, 2023
4ebf571
Try quic bbr for GT.
DrakenLibra Sep 28, 2023
b9e0609
Try quic bbr for GT.
DrakenLibra Sep 28, 2023
3a3e40b
Try quic bbr for GT.
DrakenLibra Sep 28, 2023
2ec1641
Add quic bbr for GT.
DrakenLibra Sep 28, 2023
28a5129
Complete quic bbr for GT.
DrakenLibra Sep 28, 2023
ef2a894
Complete intelligent switch for GT.
DrakenLibra Sep 28, 2023
60aae8e
Complete guideline for GT.
DrakenLibra Sep 28, 2023
bf24b86
fix container.yaml
DrakenLibra Sep 28, 2023
339624a
fix .DS_Store caused by macbook finder
DrakenLibra Sep 28, 2023
f002e94
fix .DS_Store caused by macbook finder
DrakenLibra Sep 28, 2023
d75a5fb
.DS_Store banished!
DrakenLibra Sep 28, 2023
6a89a55
Delete .DS_Store
DrakenLibra Sep 28, 2023
dc4fd7a
Add explanations for xgboost model.
DrakenLibra Sep 30, 2023
fa27250
Finish intelligent switch strategy with multiple -remote support and …
DrakenLibra Oct 13, 2023
8cf7e71
Add msquic for gt to implement QUIC bbr.
DrakenLibra Oct 26, 2023
00ce0f9
Merge branch 'dev' of github.com:ao-space/gt
DrakenLibra Oct 28, 2023
2d0d9ec
Try github ci.
DrakenLibra Oct 28, 2023
e6c0802
fix cgo in go test and try to use github ci to build.
DrakenLibra Oct 29, 2023
8eea9fe
recovery github ci action.
DrakenLibra Oct 29, 2023
7015248
Merge branch 'dev' into dev
DrakenLibra Oct 29, 2023
54a5618
have fixed dockerfile for msquic.
DrakenLibra Oct 30, 2023
b15b56b
Try to fix libmsquic.a in arm64
DrakenLibra Oct 30, 2023
214e939
Try to use different ways to fix objcopy in arm64 for msquic
DrakenLibra Oct 30, 2023
a1fd4fd
rollback makefile
DrakenLibra Oct 31, 2023
61cbd57
success for arm64 build
DrakenLibra Oct 31, 2023
f3f17d8
fix wrong deletion
DrakenLibra Oct 31, 2023
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
488 changes: 244 additions & 244 deletions .github/workflows/container.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ build
release
.vscode
.dockerignore
.idea
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,23 @@ options:
./release/linux-amd64-client -local tcp://127.0.0.1:22 -remote tcp://id1.example.com:8080 -id id1 -secret secret1 -remoteTCPPort 2222 -remoteTCPRandom
```

#### Internal QUIC Penetration

- Requirements: There is an intranet server and a public network server, and id1.example.com resolves to the address of the public network server. Hopefully by accessing id1.example.com:8080
To access the web page served by port 80 on the intranet server. At the same time, QUIC is used to build a transport connection between the client and the server.

- Server (Public network server)

```shell
./release/linux-amd64-server -addr 8080 -quicAddr 10080 -id id1 -secret secret1
```

- Client (Internal network server)

```shell
./release/linux-amd64-client -local http://127.0.0.1:80 -remote quic://id1.example.com:10080 -id id1 -secret secret1
```

#### Client Start Multiple Services Simultaneously

- Requirement: There is an internal network server and a public network server, and id1-1.example.com and
Expand Down
17 changes: 17 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ options:
./release/linux-amd64-client -local tcp://127.0.0.1:22 -remote tcp://id1.example.com:8080 -id id1 -secret secret1 -remoteTCPPort 2222 -remoteTCPRandom
```

#### QUIC 内网穿透

- 需求:有一台内网服务器和一台公网服务器,id1.example.com 解析到公网服务器的地址。希望通过访问 id1.example.com:8080
来访问内网服务器上 80 端口服务的网页。同时用 QUIC 为客户端与服务端之间构建传输连接。

- 服务端(公网服务器)

```shell
./release/linux-amd64-server -addr 8080 -quicAddr 10080 -id id1 -secret secret1
```

- 客户端(内网服务器)

```shell
./release/linux-amd64-client -local http://127.0.0.1:80 -remote quic://id1.example.com:10080 -id id1 -secret secret1
```

#### 客户端同时开启多个服务

- 需求:有一台内网服务器和一台公网服务器,id1-1.example.com 和 id1-2.example.com 解析到公网服务器的地址。希望通过访问
Expand Down
10 changes: 10 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ func (d *dialer) init(c *Client, remote string, stun string) (err error) {
}
d.host = u.Host
d.dialFn = d.dial
case "quic":
if len(u.Port()) < 1 {
u.Host = net.JoinHostPort(u.Host, "10080")
DrakenLibra marked this conversation as resolved.
Show resolved Hide resolved
}
d.host = u.Host
d.dialFn = d.quicDial
default:
err = fmt.Errorf("remote url (-remote option) '%s' is invalid", remote)
}
Expand Down Expand Up @@ -284,6 +290,10 @@ func (d *dialer) tlsDial() (conn net.Conn, err error) {
return tls.Dial("tcp", d.host, d.tlsConfig)
}

func (d *dialer) quicDial() (conn net.Conn, err error) {
return connection.QuicDial(d.host)
}

// Start runs the client agent.
func (c *Client) Start() (err error) {
c.Logger.Info().Msg(predef.Version)
Expand Down
80 changes: 80 additions & 0 deletions conn/quicConn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package conn

import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"github.com/quic-go/quic-go"
"math/big"
"net"
)

type QuicConnection struct {
quic.Connection
quic.Stream
}

type QuicListener struct {
quic.Listener
}

var _ net.Conn = &QuicConnection{}
var _ net.Listener = &QuicListener{}

func QuicDial(addr string) (net.Conn, error) {
tlsConf := &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"quic-echo-example"},
}
conn, _ := quic.DialAddr(context.Background(), addr, tlsConf, &quic.Config{})
stream, err := conn.OpenStreamSync(context.Background())
nc := &QuicConnection{
Connection: conn,
Stream: stream,
}
return nc, err
}

func QuicListen(addr string) (net.Listener, error) {
listener, err := quic.ListenAddr(addr, GenerateTLSConfig(), nil)
ln := &QuicListener{
Listener: *listener,
}
return ln, err
}

func (ln *QuicListener) Accept() (net.Conn, error) {
conn, _ := ln.Listener.Accept(context.Background())
stream, err := conn.AcceptStream(context.Background())
nc := &QuicConnection{
Connection: conn,
Stream: stream,
}
return nc, err
}

func GenerateTLSConfig() *tls.Config {
key, err := rsa.GenerateKey(rand.Reader, 1024)
DrakenLibra marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
panic(err)
}
template := x509.Certificate{SerialNumber: big.NewInt(1)}
certDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)
if err != nil {
panic(err)
}
keyPEM := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)})
certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER})

tlsCert, err := tls.X509KeyPair(certPEM, keyPEM)
if err != nil {
panic(err)
}
return &tls.Config{
Certificates: []tls.Certificate{tlsCert},
NextProtos: []string{"quic-echo-example"},
}
}
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/pion/logging v0.2.2
github.com/pion/turn/v3 v3.0.1
github.com/pkg/errors v0.9.1
github.com/quic-go/quic-go v0.35.0
github.com/rs/zerolog v1.30.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/stretchr/testify v1.8.4
Expand All @@ -24,20 +25,30 @@ require (
require (
github.com/getsentry/sentry-go v0.24.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
github.com/pion/dtls/v2 v2.2.7 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/stun/v2 v2.0.0 // indirect
github.com/pion/transport/v2 v2.2.4 // indirect
github.com/pion/transport/v3 v3.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
)
Loading