mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
ebcd59f4ba
commit
09808be1a4
1 changed files with 5 additions and 1 deletions
|
@ -12,6 +12,10 @@ import (
|
|||
|
||||
const MonitorModeAddress = "0.0.0.0"
|
||||
|
||||
var (
|
||||
IPv4Validator = regexp.MustCompile("^[0-9\\.]+/?\\d*$")
|
||||
)
|
||||
|
||||
func NormalizeMac(mac string) string {
|
||||
var parts []string
|
||||
if strings.ContainsRune(mac, '-') {
|
||||
|
@ -77,7 +81,7 @@ func FindInterface(name string) (*Endpoint, error) {
|
|||
for _, addr := range addrs {
|
||||
ip := addr.String()
|
||||
// Make sure this is an IPv4 address.
|
||||
if m, _ := regexp.MatchString("^[0-9\\.]+/?\\d*$", ip); m == true {
|
||||
if IPv4Validator.MatchString(ip) {
|
||||
if strings.IndexRune(ip, '/') == -1 {
|
||||
// plain ip
|
||||
e = NewEndpointNoResolve(ip, mac, ifName, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue