mirror of
https://github.com/bettercap/bettercap
synced 2025-07-31 04:00:09 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
efeedc7558
commit
d8ec87036e
1 changed files with 7 additions and 2 deletions
|
@ -55,6 +55,8 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
}
|
}
|
||||||
nAddrs := len(addrs)
|
nAddrs := len(addrs)
|
||||||
|
|
||||||
|
// fmt.Printf("iface=%v\n", iface)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If no interface has been specified, return the first active
|
* If no interface has been specified, return the first active
|
||||||
* one with at least an ip address, otherwise just the match
|
* one with at least an ip address, otherwise just the match
|
||||||
|
@ -62,7 +64,7 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
* if passed explicitly.
|
* if passed explicitly.
|
||||||
*/
|
*/
|
||||||
doCheck := false
|
doCheck := false
|
||||||
if name == mac {
|
if name != "" && name == mac {
|
||||||
doCheck = true
|
doCheck = true
|
||||||
} else if name == "" && ifName != "lo" && ifName != "lo0" && nAddrs > 0 {
|
} else if name == "" && ifName != "lo" && ifName != "lo0" && nAddrs > 0 {
|
||||||
doCheck = true
|
doCheck = true
|
||||||
|
@ -73,7 +75,10 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
// Also search by ip if needed.
|
// Also search by ip if needed.
|
||||||
hasIPv4 := false
|
hasIPv4 := false
|
||||||
for _, a := range addrs {
|
for _, a := range addrs {
|
||||||
hasIPv4 = IPv4Validator.MatchString(a.String())
|
if IPv4Validator.MatchString(a.String()) {
|
||||||
|
hasIPv4 = true
|
||||||
|
}
|
||||||
|
|
||||||
if name != "" && (a.String() == name || strings.HasPrefix(a.String(), name)) {
|
if name != "" && (a.String() == name || strings.HasPrefix(a.String(), name)) {
|
||||||
doCheck = true
|
doCheck = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue