mirror of
https://github.com/fumiama/terasu-cloudflared.git
synced 2026-06-09 04:30:31 +08:00
feat: embed terasu inside
This commit is contained in:
22
vendor/github.com/miekg/dns/client.go
generated
vendored
22
vendor/github.com/miekg/dns/client.go
generated
vendored
@@ -10,6 +10,8 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fumiama/terasu"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -131,11 +133,23 @@ func (c *Client) DialContext(ctx context.Context, address string) (conn *Conn, e
|
||||
if useTLS {
|
||||
network = strings.TrimSuffix(network, "-tls")
|
||||
|
||||
tlsDialer := tls.Dialer{
|
||||
NetDialer: &d,
|
||||
Config: c.TLSConfig,
|
||||
var rawConn net.Conn
|
||||
rawConn, err = d.DialContext(ctx, network, address)
|
||||
if err == nil {
|
||||
tlsCn := tls.Client(terasu.NewConn(rawConn), c.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.Conn = tlsCn
|
||||
}
|
||||
}
|
||||
conn.Conn, err = tlsDialer.DialContext(ctx, network, address)
|
||||
} else {
|
||||
conn.Conn, err = d.DialContext(ctx, network, address)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user