mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 16:13:48 -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)
|
||||
}
|
||||
|
||||
func (t *Endpoint) IsMonitor() bool {
|
||||
return t.IpAddress == MonitorModeAddress
|
||||
}
|
||||
|
||||
func (t *Endpoint) String() string {
|
||||
if t.HwAddress == "" {
|
||||
return t.IpAddress
|
||||
|
|
|
@ -54,15 +54,17 @@ func NewQueue(iface *network.Endpoint) (q *Queue, err error) {
|
|||
Activities: make(chan Activity),
|
||||
|
||||
iface: iface,
|
||||
active: true,
|
||||
active: !iface.IsMonitor(),
|
||||
}
|
||||
|
||||
if q.handle, err = pcap.OpenLive(iface.Name(), 1024, true, pcap.BlockForever); err != nil {
|
||||
return
|
||||
}
|
||||
if q.active == true {
|
||||
if q.handle, err = pcap.OpenLive(iface.Name(), 1024, true, pcap.BlockForever); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
q.source = gopacket.NewPacketSource(q.handle, q.handle.LinkType())
|
||||
go q.worker()
|
||||
q.source = gopacket.NewPacketSource(q.handle, q.handle.LinkType())
|
||||
go q.worker()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -168,6 +170,9 @@ func (q *Queue) Send(raw []byte) error {
|
|||
func (q *Queue) Stop() {
|
||||
q.Lock()
|
||||
defer q.Unlock()
|
||||
q.handle.Close()
|
||||
q.active = false
|
||||
|
||||
if q.active == true {
|
||||
q.handle.Close()
|
||||
q.active = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue