Skip to content

Commit

Permalink
Handle IPv6 in isMovedError
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddzxy committed Apr 25, 2024
1 parent 90c7a41 commit 3d4267b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions error.go
Expand Up @@ -129,7 +129,20 @@ func isMovedError(err error) (moved bool, ask bool, addr string) {
if ind == -1 {
return false, false, ""
}

addr = s[ind+1:]
ind = strings.LastIndex(addr, ":")
if ind == -1 {
return false, false, ""
}

h := addr[:ind]
p := addr[ind+1:]
if strings.HasSuffix(h, "]") {
return
}

addr = net.JoinHostPort(h, p)
return
}

Expand Down

0 comments on commit 3d4267b

Please sign in to comment.