mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
fix: refactored routing logic (fixes #701)
This commit is contained in:
parent
88a83192ef
commit
43a93fd866
11 changed files with 202 additions and 80 deletions
|
@ -3,25 +3,11 @@ package network
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/google/gopacket/pcap"
|
||||
)
|
||||
|
||||
// only matches gateway lines
|
||||
var IPv4RouteParser = regexp.MustCompile("^.+\\s+.+\\s+\\d+\\s+([0-9\\.]+/\\d+)\\s+\\d+\\s+([0-9\\.]+).*$")
|
||||
var IPv4RouteTokens = 3
|
||||
var IPv4RouteCmd = "netsh"
|
||||
var IPv4RouteCmdOpts = []string{"interface", "ipv4", "show", "route"}
|
||||
|
||||
func IPv4RouteIsGateway(ifname string, tokens []string, f func(gateway string) (*Endpoint, error)) (*Endpoint, error) {
|
||||
// TODO check if the subnet is the same as iface ?
|
||||
// subnet := tokens[1]
|
||||
gateway := tokens[2]
|
||||
return f(gateway)
|
||||
}
|
||||
|
||||
/*
|
||||
* net.Interface does not have the correct name on Windows and pcap.Interface
|
||||
* does not have the hardware address for some reason ... so this is what I
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue