mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
17952a3904
commit
a6e87618d4
2 changed files with 17 additions and 14 deletions
|
@ -53,15 +53,14 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
|||
func GatewayProvidedByUser(iface *Endpoint, gateway string) (*Endpoint, error) {
|
||||
Debug("GatewayProvidedByUser(%s) [cmd=%v opts=%v parser=%v]", gateway, IPv4RouteCmd, IPv4RouteCmdOpts, IPv4RouteParser)
|
||||
if IPv4Validator.MatchString(gateway) {
|
||||
Debug("valid gateway ip %s",gateway)
|
||||
ifName := iface.Name()
|
||||
Debug("valid gateway ip %s", gateway)
|
||||
// we have the address, now we need its mac
|
||||
mac, err := ArpLookup(ifName, gateway, false)
|
||||
if err != nil {
|
||||
if mac, err := ArpLookup(iface.Name(), gateway, false); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
Debug("gateway is %s[%s]", gateway, mac)
|
||||
return NewEndpoint(gateway, mac), nil
|
||||
}
|
||||
Debug("gateway is %s[%s]", gateway, mac)
|
||||
return NewEndpoint(gateway, mac), nil
|
||||
}
|
||||
return nil, fmt.Errorf("Provided gateway %s not a valid IPv4 address! Revert to find default gateway.",gateway)
|
||||
return nil, fmt.Errorf("Provided gateway %s not a valid IPv4 address! Revert to find default gateway.", gateway)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue