Add brackets to IPv6 literals with standard ports (#329)
Co-authored-by: erik <fake@not.real> https://github.com/zmap/zgrab2/pull/329
This commit is contained in:
parent
8dadfc8509
commit
d753afcd25
|
@ -427,9 +427,15 @@ func getHTTPURL(https bool, host string, port uint16, endpoint string) string {
|
|||
} else {
|
||||
proto = "http"
|
||||
}
|
||||
if protoToPort[proto] == port {
|
||||
if protoToPort[proto] == port && strings.Contains(host, ":") {
|
||||
//If the host has a ":" in it, assume literal IPv6 address
|
||||
return proto + "://[" + host + "]" + endpoint
|
||||
} else if protoToPort[proto] == port {
|
||||
//Otherwise, just concatenate host and endpoint
|
||||
return proto + "://" + host + endpoint
|
||||
}
|
||||
|
||||
//For non-default ports, net.JoinHostPort will handle brackets for IPv6 literals
|
||||
return proto + "://" + net.JoinHostPort(host, strconv.FormatUint(uint64(port), 10)) + endpoint
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue