mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: adopt new IPv4 parsing logic
This commit is contained in:
parent
eee94e993c
commit
44a17602ed
1 changed files with 9 additions and 10 deletions
|
@ -196,17 +196,16 @@ func buildEndpointFromInterface(iface net.Interface) (*Endpoint, error) {
|
|||
|
||||
for _, a := range addrs {
|
||||
address := a.String()
|
||||
if IPv4Validator.MatchString(address) {
|
||||
if !strings.ContainsRune(address, '/') {
|
||||
// plain ip
|
||||
e.SetIP(address)
|
||||
} else {
|
||||
// ip/bits
|
||||
e.SetNetwork(address)
|
||||
}
|
||||
} else {
|
||||
// ipv6/xxx
|
||||
switch true {
|
||||
case IPv4Validator.MatchString(address):
|
||||
e.SetIP(address)
|
||||
break
|
||||
case IPv4BlockValidator.MatchString(address):
|
||||
e.SetNetwork(address)
|
||||
break
|
||||
default:
|
||||
e.SetIPv6(address)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue