mirror of
https://github.com/bettercap/bettercap
synced 2025-07-13 00:23:49 -07:00
fix: not starting packet queue if the interface is in monitor mode
This commit is contained in:
parent
9d69e238a0
commit
b48bb8c31c
2 changed files with 17 additions and 8 deletions
|
@ -100,6 +100,10 @@ func (t *Endpoint) CIDR() string {
|
||||||
return fmt.Sprintf("%s/%d", ip.String(), t.SubnetBits)
|
return fmt.Sprintf("%s/%d", ip.String(), t.SubnetBits)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Endpoint) IsMonitor() bool {
|
||||||
|
return t.IpAddress == MonitorModeAddress
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Endpoint) String() string {
|
func (t *Endpoint) String() string {
|
||||||
if t.HwAddress == "" {
|
if t.HwAddress == "" {
|
||||||
return t.IpAddress
|
return t.IpAddress
|
||||||
|
|
|
@ -54,15 +54,17 @@ func NewQueue(iface *network.Endpoint) (q *Queue, err error) {
|
||||||
Activities: make(chan Activity),
|
Activities: make(chan Activity),
|
||||||
|
|
||||||
iface: iface,
|
iface: iface,
|
||||||
active: true,
|
active: !iface.IsMonitor(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q.active == true {
|
||||||
if q.handle, err = pcap.OpenLive(iface.Name(), 1024, true, pcap.BlockForever); err != nil {
|
if q.handle, err = pcap.OpenLive(iface.Name(), 1024, true, pcap.BlockForever); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
q.source = gopacket.NewPacketSource(q.handle, q.handle.LinkType())
|
q.source = gopacket.NewPacketSource(q.handle, q.handle.LinkType())
|
||||||
go q.worker()
|
go q.worker()
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -168,6 +170,9 @@ func (q *Queue) Send(raw []byte) error {
|
||||||
func (q *Queue) Stop() {
|
func (q *Queue) Stop() {
|
||||||
q.Lock()
|
q.Lock()
|
||||||
defer q.Unlock()
|
defer q.Unlock()
|
||||||
|
|
||||||
|
if q.active == true {
|
||||||
q.handle.Close()
|
q.handle.Close()
|
||||||
q.active = false
|
q.active = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue