Fix ip/cname resolve bug

When the url's format like: https://www.google.com:443, the domain pass
 to the resolver will be www.google.com:443 and can't get the right
 result

 This patch split the port at the start of the function and rewrite the
 domain to the right format, which makes the result of IP/Cname be
 right.
This commit is contained in:
Melody 2021-04-27 14:04:10 +08:00
parent 48f2532f84
commit 28ef5a12e0

View File

@ -520,6 +520,12 @@ retry:
URL := fmt.Sprintf("%s://%s", protocol, domain)
if port > 0 {
URL = fmt.Sprintf("%s://%s:%d", protocol, domain, port)
} else {
domainParse := strings.Split(domain, ":")
domain = domainParse[0]
if len(domainParse) > 1 {
port, _ = strconv.Atoi(domainParse[1])
}
}
if !scanopts.Unsafe {
@ -692,7 +698,6 @@ retry:
builder.WriteString(" [http2]")
}
}
ip := hp.Dialer.GetDialedIP(domain)
if scanopts.OutputIP {
builder.WriteString(fmt.Sprintf(" [%s]", ip))