Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cbb06f2

Browse files
committedApr 25, 2024
Handle IPv6 in isMovedError
1 parent 90c7a41 commit cbb06f2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎error.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,18 @@ 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+
if string(addr[ind-1]) == "]" {
140+
return
141+
}
142+
143+
addr = net.JoinHostPort(addr[:ind], addr[ind+1:])
133144
return
134145
}
135146

0 commit comments

Comments
 (0)
Please sign in to comment.