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

Use network "tcp" when calling tls.DialWithDialer #56

Merged
merged 2 commits into from
Aug 20, 2024
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
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewClient(addr, net string) Client {
// SetTLSConfig sets tls config for client
func (c *client) SetTLSConfig(cfg *tls.Config) {
if cfg != nil {
c.net = tcptlc
c.net = tcptls
}
c.transport.SetTLSConfig(cfg)
}
Expand Down
2 changes: 1 addition & 1 deletion const.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
defaultTimeout = 30 * time.Second
readTimeout = 2 * time.Second
attemptDelay = time.Millisecond * 100
tcptlc = "tcp-tls"
tcptls = "tcp-tls"
tcp = "tcp"
udp = "udp"
)
2 changes: 1 addition & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func parseProtocol(f *Fanout, c *caddyfile.Dispenser) error {
return c.ArgErr()
}
net := strings.ToLower(c.Val())
if net != tcp && net != udp && net != tcptlc {
if net != tcp && net != udp && net != tcptls {
return errors.New("unknown network protocol")
}
f.net = net
Expand Down
8 changes: 4 additions & 4 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func (t *transportImpl) SetTLSConfig(c *tls.Config) {
// Dial dials the address configured in transportImpl, potentially reusing a connection or creating a new one.
func (t *transportImpl) Dial(ctx context.Context, network string) (*dns.Conn, error) {
if t.tlsConfig != nil {
network = tcptlc
network = tcptls
}
if network == tcptlc {
if network == tcptls {
return t.dial(ctx, &dns.Client{Net: network, Dialer: &net.Dialer{Timeout: maxTimeout}, TLSConfig: t.tlsConfig})
}
return t.dial(ctx, &dns.Client{Net: network, Dialer: &net.Dialer{Timeout: maxTimeout}})
Expand All @@ -78,8 +78,8 @@ func (t *transportImpl) dial(ctx context.Context, c *dns.Client) (*dns.Conn, err
}
var conn = new(dns.Conn)
var err error
if network == tcptlc {
conn.Conn, err = tls.DialWithDialer(&d, network, t.addr, c.TLSConfig)
if network == tcptls {
conn.Conn, err = tls.DialWithDialer(&d, "tcp", t.addr, c.TLSConfig)
} else {
conn.Conn, err = d.DialContext(ctx, network, t.addr)
}
Expand Down
Loading