mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
7ec7c20db8
commit
e6bd5a9584
3 changed files with 70 additions and 45 deletions
32
network/net_gateway_android.go
Normal file
32
network/net_gateway_android.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package net
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/bettercap/bettercap/core"
|
||||
)
|
||||
|
||||
func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
||||
output, err = core.Exec("getprop", []string{"net.dns1"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gw := core.Trim(output)
|
||||
if IPv4Validator.MatchString(gw) {
|
||||
// we have the address, now we need its mac
|
||||
mac, err := ArpLookup(iface.Name(), gw, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewEndpoint(gateway, mac), nil
|
||||
}
|
||||
|
||||
return nil, ErrNoGateway
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue