misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2019-02-12 10:18:34 +01:00
commit a6e87618d4
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 17 additions and 14 deletions

View file

@ -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)
}