Skip to content

Commit 76330b0

Browse files
committed
force ipv4 only
1 parent 41d5228 commit 76330b0

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cmd/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func isDebug() bool {
1414
return false
1515
}
1616
func isTrace() bool {
17-
return true
17+
return false
1818
}
1919

2020
func ValidateCommand(exitCode int){
@@ -24,7 +24,7 @@ func ValidateCommand(exitCode int){
2424
}
2525
func Command(name string, arg...string) int{
2626
if isDebug() {
27-
log.Println(name,arg)
27+
//log.Println(name,arg)
2828
return 0
2929
}else{
3030
cmd := exec.Command(name, arg...)

mesh/publicIPRepository.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,32 @@ import (
1313

1414
type publicIPRepoProviders struct{
1515
providers []string
16+
transport *http.Transport
1617
}
1718

1819

1920

2021
func NewPublicIPRepository() PublicIPRepository {
2122
var providers = []string{"https://api.ipify.org/","http://ifconfig.io/ip","http://ipecho.net/plain","http://icanhazip.com","https://ifconfig.me/ip","https://myexternalip.com/raw"}
23+
2224
dialer := &net.Dialer{
23-
Timeout: time.Duration(5 * time.Second),
25+
Timeout: 10 * time.Second,
26+
KeepAlive: 10 * time.Second,
27+
}
28+
29+
var MyTransport = &http.Transport{
30+
DialContext: dialer.DialContext,
31+
MaxIdleConns: 100,
32+
IdleConnTimeout: 90 * time.Second,
33+
TLSHandshakeTimeout: 10 * time.Second,
34+
ExpectContinueTimeout: 1 * time.Second,
2435
}
25-
http.DefaultTransport.(*http.Transport).DialContext = func(ctx context.Context, _, addr string) (net.Conn, error) {
36+
MyTransport.DialContext = func(ctx context.Context, _, addr string) (net.Conn, error) {
2637
return dialer.DialContext(ctx, "tcp4", addr)
2738
}
2839
return &publicIPRepoProviders{
2940
providers: providers,
41+
transport: MyTransport,
3042
}
3143
}
3244

0 commit comments

Comments
 (0)