File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -74,10 +74,14 @@ func (this *HttpPing) PingContext(ctx context.Context) IPingResult {
74
74
return this .errorResult (err )
75
75
}
76
76
}
77
+ ipstr := ip .String ()
78
+ if isIPv6 (ip ) {
79
+ ipstr = fmt .Sprintf ("[%s]" , ipstr )
80
+ }
77
81
if port != "" {
78
- u .Host = net . JoinHostPort ( ip . String () , port )
82
+ u .Host = fmt . Sprintf ( "%s:%s" , ipstr , port )
79
83
} else {
80
- u .Host = ip . String ()
84
+ u .Host = ipstr
81
85
}
82
86
url2 := u .String ()
83
87
Original file line number Diff line number Diff line change @@ -99,3 +99,12 @@ func TestQuic(t *testing.T) {
99
99
t .Fatal (result .Error ())
100
100
}
101
101
}
102
+
103
+ func TestHttpIPv6 (t * testing.T ) {
104
+ p := ping .NewHttpPing ("GET" , "https://www.qq.com/" , time .Second * 5 )
105
+ p .IP , _ = ping .LookupIPv6 ("www.qq.com" )
106
+ result := p .Ping ()
107
+ if result .Error () != nil {
108
+ t .Fatal (result .Error ())
109
+ }
110
+ }
You can’t perform that action at this time.
0 commit comments