mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
simplify interface IPv4 address parsing
This commit is contained in:
parent
44a17602ed
commit
e255eba69f
1 changed files with 2 additions and 2 deletions
|
@ -254,7 +254,7 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
|
|
||||||
// user did not provide an interface name,
|
// user did not provide an interface name,
|
||||||
// return the first one with a valid ipv4
|
// return the first one with a valid ipv4
|
||||||
// address
|
// address that does not loop back
|
||||||
for _, iface := range ifaces {
|
for _, iface := range ifaces {
|
||||||
addrs, err := iface.Addrs()
|
addrs, err := iface.Addrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -264,7 +264,7 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
|
|
||||||
for _, address := range addrs {
|
for _, address := range addrs {
|
||||||
ip := address.String()
|
ip := address.String()
|
||||||
if !strings.Contains(ip, "127.0.0.1") && IPv4Validator.MatchString(ip) {
|
if ip != "127.0.0.1" && IPv4Validator.MatchString(ip) {
|
||||||
return buildEndpointFromInterface(iface)
|
return buildEndpointFromInterface(iface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue