mirror of
https://github.com/bettercap/bettercap
synced 2025-07-29 19:20:00 -07:00
fixes
This commit is contained in:
parent
6b89145e80
commit
1ee605d01d
2 changed files with 20 additions and 9 deletions
|
@ -99,17 +99,27 @@ func (d *Discovery) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if n_gw_shared > 0 {
|
if n_gw_shared > 0 {
|
||||||
log.Warningf("WARNING: %d endpoints share the same MAC of the gateway, there're might be some IP isolation going on.\n", n_gw_shared)
|
a := ""
|
||||||
|
b := ""
|
||||||
|
if n_gw_shared == 1 {
|
||||||
|
a = ""
|
||||||
|
b = "s"
|
||||||
|
} else {
|
||||||
|
a = "s"
|
||||||
|
b = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warningf("WARNING: Found %d endpoint%s which share%s the same MAC of the gateway (%s), there're might be some IP isolation going on, skipping.\n", n_gw_shared, a, b, d.Session.Gateway.HwAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh target pool
|
// refresh target pool
|
||||||
for ip, mac := range new {
|
|
||||||
d.Session.Targets.AddIfNotExist(ip, mac)
|
|
||||||
}
|
|
||||||
|
|
||||||
for ip, mac := range rem {
|
for ip, mac := range rem {
|
||||||
d.Session.Targets.Remove(ip, mac)
|
d.Session.Targets.Remove(ip, mac)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ip, mac := range new {
|
||||||
|
d.Session.Targets.AddIfNotExist(ip, mac)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.before = d.current
|
d.before = d.current
|
||||||
|
|
|
@ -56,22 +56,23 @@ func (tp *Targets) Has(ip string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tp *Targets) AddIfNotExist(ip, mac string) {
|
func (tp *Targets) AddIfNotExist(ip, mac string) *net.Endpoint {
|
||||||
tp.lock.Lock()
|
tp.lock.Lock()
|
||||||
defer tp.lock.Unlock()
|
defer tp.lock.Unlock()
|
||||||
|
|
||||||
if tp.shouldIgnore(ip) {
|
if tp.shouldIgnore(ip) {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, found := tp.Targets[mac]; found {
|
if t, found := tp.Targets[mac]; found {
|
||||||
t.IpAddress = ip
|
return t
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e := net.NewEndpoint(ip, mac)
|
e := net.NewEndpoint(ip, mac)
|
||||||
log.Infof("[%snew%s] %s\n", core.GREEN, core.RESET, e)
|
log.Infof("[%snew%s] %s\n", core.GREEN, core.RESET, e)
|
||||||
tp.Targets[mac] = e
|
tp.Targets[mac] = e
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type tSorter []*net.Endpoint
|
type tSorter []*net.Endpoint
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue