| 1 | package sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/bettercap/bettercap/networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/" |
| 5 | "github.com/bettercap/bettercap/routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/" |
| 6 | "github.com/evilsocket/islazy/logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/" |
| 7 | "timescip-go gomod github.com/golang/go/src go1.16 time/" |
| 8 | ) |
| 9 | |
| 10 | type gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway# struct { |
| 11 | IPscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#IP. string `json:"ip"` |
| 12 | MACscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#MAC. string `json:"mac"` |
| 13 | } |
| 14 | |
| 15 | type GatewayChangescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange# struct { |
| 16 | Typescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#Type. string `json:"type"` |
| 17 | Prevscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#Prev. gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway# `json:"prev"` |
| 18 | Newscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#New. gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway# `json:"new"` |
| 19 | } |
| 20 | |
| 21 | func (s *Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#) routeMonscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#routeMon().() { |
| 22 | var err error |
| 23 | var gw4 *networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/.Endpointscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint# |
| 24 | var gwIP6, gwMAC6 string |
| 25 | |
| 26 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.INFOscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/INFO., "gateway monitor started ...") |
| 27 | |
| 28 | if gw4 = s.Gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Gateway.; gw4 == nil { |
| 29 | gw4 = &networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/.Endpointscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#{} |
| 30 | } |
| 31 | |
| 32 | gwIP6, err = routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/.Gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/Gateway().(routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/.IPv6scip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/IPv6., s.Interfacescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Interface..Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#Name().()) |
| 33 | if err != nil { |
| 34 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.ERRORscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/ERROR., "error getting ipv6 gateway: %v", err) |
| 35 | } else if gwIP6 != "" { |
| 36 | gwMAC6, err = networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/.ArpLookupscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/ArpLookup().(s.Interfacescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Interface..Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#Name().(), gwIP6, true) |
| 37 | if err != nil { |
| 38 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.DEBUGscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/DEBUG., "error getting %s ipv6 gateway mac: %v", gwIP6, err) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | for { |
| 43 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.DEBUGscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/DEBUG., "[gw] ipv4=%s(%s) ipv6=%s(%s)", gw4.IPscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#IP., gw4.HwAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#HwAddress., gwIP6, gwMAC6) |
| 44 | |
| 45 | timescip-go gomod github.com/golang/go/src go1.16 time/.Sleepscip-go gomod github.com/golang/go/src go1.16 time/Sleep().(5 * timescip-go gomod github.com/golang/go/src go1.16 time/.Secondscip-go gomod github.com/golang/go/src go1.16 time/Second.) |
| 46 | |
| 47 | gw4now, err := networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/.FindGatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/FindGateway().(s.Interfacescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Interface.) |
| 48 | if gw4now == nil { |
| 49 | gw4now = &networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/.Endpointscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#{} |
| 50 | } |
| 51 | |
| 52 | if err != nil { |
| 53 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.ERRORscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/ERROR., "error getting ipv4 gateway: %v", err) |
| 54 | } else { |
| 55 | if gw4now.IpAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#IpAddress. != gw4.IpAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#IpAddress. || gw4now.HwAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#HwAddress. != gw4.HwAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#HwAddress. { |
| 56 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Addscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Add().("gateway.change", GatewayChangescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#{ |
| 57 | Typescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#Type.: string(routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/.IPv4scip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/IPv4.), |
| 58 | Prevscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#Prev.: gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#{ |
| 59 | IPscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#IP.: gw4.IpAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#IpAddress., |
| 60 | MACscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#MAC.: gw4.HwAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#HwAddress., |
| 61 | }, |
| 62 | Newscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#New.: gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#{ |
| 63 | IPscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#IP.: gw4now.IpAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#IpAddress., |
| 64 | MACscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#MAC.: gw4now.HwAddressscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#HwAddress., |
| 65 | }, |
| 66 | }) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | gw4 = gw4now |
| 71 | |
| 72 | gwMAC6now := "" |
| 73 | gwIP6now, err := routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/.Gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/Gateway().(routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/.IPv6scip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/IPv6., s.Interfacescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Interface..Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#Name().()) |
| 74 | if err != nil { |
| 75 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.ERRORscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/ERROR., "error getting ipv6 gateway: %v", err) |
| 76 | } else if gwIP6now != "" { |
| 77 | gwMAC6now, err = networkscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/.ArpLookupscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/ArpLookup().(s.Interfacescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Interface..Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/network`/Endpoint#Name().(), gwIP6now, true) |
| 78 | if err != nil { |
| 79 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Logscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Log().(logscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/.DEBUGscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/log`/DEBUG., "error getting %s ipv6 gateway mac: %v", gwIP6now, err) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if gwIP6now != gwIP6 || gwMAC6now != gwMAC6 { |
| 84 | s.Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Addscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Add().("gateway.change", GatewayChangescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#{ |
| 85 | Typescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#Type.: string(routingscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/.IPv6scip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/routing`/IPv6.), |
| 86 | Prevscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#Prev.: gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#{ |
| 87 | IPscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#IP.: gwIP6, |
| 88 | MACscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#MAC.: gwMAC6, |
| 89 | }, |
| 90 | Newscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/GatewayChange#New.: gatewayscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#{ |
| 91 | IPscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#IP.: gwIP6now, |
| 92 | MACscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/gateway#MAC.: gwMAC6now, |
| 93 | }, |
| 94 | }) |
| 95 | } |
| 96 | |
| 97 | gwIP6 = gwIP6now |
| 98 | gwMAC6 = gwMAC6now |
| 99 | } |
| 100 | } |