Skip to content

Commit 3d4267b

Browse files
committed
Handle IPv6 in isMovedError
1 parent 90c7a41 commit 3d4267b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

error.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,20 @@ func isMovedError(err error) (moved bool, ask bool, addr string) {
129129
if ind == -1 {
130130
return false, false, ""
131131
}
132+
132133
addr = s[ind+1:]
134+
ind = strings.LastIndex(addr, ":")
135+
if ind == -1 {
136+
return false, false, ""
137+
}
138+
139+
h := addr[:ind]
140+
p := addr[ind+1:]
141+
if strings.HasSuffix(h, "]") {
142+
return
143+
}
144+
145+
addr = net.JoinHostPort(h, p)
133146
return
134147
}
135148

0 commit comments

Comments
 (0)