Debian Codegraph @

network/net_gateway_android.go

raw symbols SCIP
1 package network
2
3 import (
4 "github.com/bettercap/bettercap/core"
5
6 "github.com/evilsocket/islazy/str"
7 )
8
9 // Hi, i'm Android and my mum said I'm special.
10 func FindGateway(iface *Endpoint) (*Endpoint, error) {
11 output, err := core.Exec("getprop", []string{"net.dns1"})
12 if err != nil {
13 return nil, err
14 }
15
16 gw := str.Trim(output)
17 if IPv4Validator.MatchString(gw) {
18 // we have the address, now we need its mac
19 mac, err := ArpLookup(iface.Name(), gw, false)
20 if err != nil {
21 return nil, err
22 }
23 return NewEndpoint(gw, mac), nil
24 }
25
26 return nil, ErrNoGateway
27 }