mirror of
https://github.com/fumiama/terasu-cloudflared.git
synced 2026-06-26 23:20:27 +08:00
feat: embed terasu inside
This commit is contained in:
18
vendor/golang.org/x/net/http2/transport.go
generated
vendored
18
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@@ -31,6 +31,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/fumiama/terasu"
|
||||
"golang.org/x/net/http/httpguts"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"golang.org/x/net/idna"
|
||||
@@ -3275,13 +3276,22 @@ func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.M
|
||||
// dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS
|
||||
// connection.
|
||||
func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
|
||||
dialer := &tls.Dialer{
|
||||
Config: cfg,
|
||||
}
|
||||
dialer := &net.Dialer{}
|
||||
cn, err := dialer.DialContext(ctx, network, addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed
|
||||
tlsCn := tls.Client(terasu.NewConn(cn), cfg)
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
cn.SetDeadline(deadline)
|
||||
}
|
||||
err = tlsCn.Handshake()
|
||||
if _, ok := ctx.Deadline(); ok {
|
||||
cn.SetDeadline(time.Time{})
|
||||
}
|
||||
if err != nil {
|
||||
cn.Close()
|
||||
return nil, err
|
||||
}
|
||||
return tlsCn, nil
|
||||
}
|
||||
|
||||
24
vendor/golang.org/x/net/websocket/dial.go
generated
vendored
24
vendor/golang.org/x/net/websocket/dial.go
generated
vendored
@@ -8,6 +8,9 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/fumiama/terasu"
|
||||
)
|
||||
|
||||
func dialWithDialer(ctx context.Context, dialer *net.Dialer, config *Config) (conn net.Conn, err error) {
|
||||
@@ -16,12 +19,23 @@ func dialWithDialer(ctx context.Context, dialer *net.Dialer, config *Config) (co
|
||||
conn, err = dialer.DialContext(ctx, "tcp", parseAuthority(config.Location))
|
||||
|
||||
case "wss":
|
||||
tlsDialer := &tls.Dialer{
|
||||
NetDialer: dialer,
|
||||
Config: config.TlsConfig,
|
||||
var rawConn net.Conn
|
||||
rawConn, err = dialer.DialContext(ctx, "tcp", parseAuthority(config.Location))
|
||||
if err == nil {
|
||||
tlsCn := tls.Client(terasu.NewConn(rawConn), config.TlsConfig)
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
rawConn.SetDeadline(deadline)
|
||||
}
|
||||
err = tlsCn.Handshake()
|
||||
if _, ok := ctx.Deadline(); ok {
|
||||
rawConn.SetDeadline(time.Time{})
|
||||
}
|
||||
if err != nil {
|
||||
rawConn.Close()
|
||||
} else {
|
||||
conn = tlsCn
|
||||
}
|
||||
}
|
||||
|
||||
conn, err = tlsDialer.DialContext(ctx, "tcp", parseAuthority(config.Location))
|
||||
default:
|
||||
err = ErrBadScheme
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user