Skip to content

Commit ee91c43

Browse files
authored
Merge pull request #103 from Snawoot/fixes
Fixes
2 parents 8c3f3d2 + ccaee61 commit ee91c43

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

dialer/selection.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dialer
22

33
import (
44
"context"
5+
"crypto/tls"
56
"errors"
67
"fmt"
78
"io"
@@ -63,14 +64,16 @@ func SelectRandom(_ context.Context, dialers []ContextDialer) (ContextDialer, er
6364
return dialers[rand.IntN(len(dialers))], nil
6465
}
6566

66-
func probeDialer(ctx context.Context, dialer ContextDialer, url string, dlLimit int64) error {
67+
func probeDialer(ctx context.Context, dialer ContextDialer, url string, dlLimit int64, tlsClientConfig *tls.Config) error {
6768
httpClient := http.Client{
6869
Transport: &http.Transport{
6970
MaxIdleConns: 100,
7071
IdleConnTimeout: 90 * time.Second,
7172
TLSHandshakeTimeout: 10 * time.Second,
7273
ExpectContinueTimeout: 1 * time.Second,
7374
DialContext: dialer.DialContext,
75+
TLSClientConfig: tlsClientConfig,
76+
ForceAttemptHTTP2: true,
7477
},
7578
}
7679
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
@@ -93,7 +96,7 @@ func probeDialer(ctx context.Context, dialer ContextDialer, url string, dlLimit
9396
return err
9497
}
9598

96-
func NewFastestServerSelectionFunc(url string, dlLimit int64) SelectionFunc {
99+
func NewFastestServerSelectionFunc(url string, dlLimit int64, tlsClientConfig *tls.Config) SelectionFunc {
97100
return func(ctx context.Context, dialers []ContextDialer) (ContextDialer, error) {
98101
var resErr error
99102
masterNotInterested := make(chan struct{})
@@ -102,7 +105,7 @@ func NewFastestServerSelectionFunc(url string, dlLimit int64) SelectionFunc {
102105
success := make(chan ContextDialer)
103106
for _, dialer := range dialers {
104107
go func(dialer ContextDialer) {
105-
err := probeDialer(ctx, dialer, url, dlLimit)
108+
err := probeDialer(ctx, dialer, url, dlLimit, tlsClientConfig)
106109
if err == nil {
107110
select {
108111
case success <- dialer:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
1010
github.com/hashicorp/go-multierror v1.1.1
1111
github.com/ncruces/go-dns v1.2.7
12-
golang.org/x/net v0.43.0
12+
golang.org/x/net v0.44.0
1313
)
1414

1515
require github.com/hashicorp/errwrap v1.1.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
99
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
1010
github.com/ncruces/go-dns v1.2.7 h1:NMA7vFqXUl+nBhGFlleLyo2ni3Lqv3v+qFWZidzRemI=
1111
github.com/ncruces/go-dns v1.2.7/go.mod h1:SqmhVMBd8Wr7hsu3q6yTt6/Jno/xLMrbse/JLOMBo1Y=
12-
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
13-
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
12+
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
13+
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ func run() int {
366366
ss = dialer.NewFastestServerSelectionFunc(
367367
args.serverSelectionTestURL,
368368
args.serverSelectionDLLimit,
369+
&tls.Config{
370+
RootCAs: caPool,
371+
},
369372
)
370373
default:
371374
panic("unhandled server selection value got past parsing")

0 commit comments

Comments
 (0)