1
0
mirror of https://github.com/bettercap/bettercap.git synced 2025-03-12 04:36:03 -07:00

simplify interface IPv4 address parsing

This commit is contained in:
☸️ 2021-09-20 16:52:53 +10:00 committed by GitHub
parent 44a17602ed
commit e255eba69f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -254,7 +254,7 @@ func FindInterface(name string) (*Endpoint, error) {
// user did not provide an interface name,
// return the first one with a valid ipv4
// address
// address that does not loop back
for _, iface := range ifaces {
addrs, err := iface.Addrs()
if err != nil {
@ -264,7 +264,7 @@ func FindInterface(name string) (*Endpoint, error) {
for _, address := range addrs {
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)
}
}