improve: use IndexByte to find the colon of ip address (#92)

This commit is contained in:
UUBulb authored and GitHub committed 2024-11-24 01:02:40 +08:00
1 parent ee37e35eb2
commit 88efe2d1d5
3 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -72,12 +72,12 @@ func resolveIP(addr string, ipv6 bool) (string, error) {
for i := 0; i < len(res); i++ {
ip := res[i].String()
if strings.Contains(ip, ".") && !ipv6 {
if strings.IndexByte(ip, '.') != -1 && !ipv6 {
ipv4Resolved = true
url[0] = ip
break
}
if strings.Contains(ip, ":") && ipv6 {
if strings.IndexByte(ip, ':') != -1 && ipv6 {
ipv6Resolved = true
url[0] = "[" + ip + "]"
break