File tree Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212 "slices"
1313 "strings"
1414 "sync"
15+ "sync/atomic"
1516 "time"
1617
1718 "github.com/malfunkt/iprange"
@@ -156,19 +157,20 @@ func (at *ARPTable) Refresh() error {
156157}
157158
158159type ARPSpoofer struct {
159- targets []netip.Addr
160- gwIP netip.Addr
161- gwMAC net.HardwareAddr
162- iface * net.Interface
163- hostIP netip.Addr
164- hostMAC net.HardwareAddr
165- fullduplex bool
166- arpTable * ARPTable
167- packets chan * Packet
168- logger * zerolog.Logger
169- quit chan bool
170- wg sync.WaitGroup
171- p * packet.Conn
160+ targets []netip.Addr
161+ gwIP netip.Addr
162+ gwMAC net.HardwareAddr
163+ iface * net.Interface
164+ hostIP netip.Addr
165+ hostMAC net.HardwareAddr
166+ fullduplex bool
167+ startingFlag atomic.Bool
168+ arpTable * ARPTable
169+ packets chan * Packet
170+ logger * zerolog.Logger
171+ quit chan bool
172+ wg sync.WaitGroup
173+ p * packet.Conn
172174}
173175
174176func NewARPSpoofer (conf * ARPSpoofConfig ) (* ARPSpoofer , error ) {
@@ -302,6 +304,7 @@ func NewARPSpoofer(conf *ARPSpoofConfig) (*ARPSpoofer, error) {
302304}
303305
304306func (ar * ARPSpoofer ) Start () {
307+ ar .startingFlag .Store (true )
305308 ar .logger .Info ().Msg ("[arp spoofer] Started" )
306309 go ar .handlePackets ()
307310 ar .logger .Debug ().Msgf ("[arp spoofer] Probing %d targets" , len (ar .targets ))
@@ -312,6 +315,7 @@ func (ar *ARPSpoofer) Start() {
312315 go ar .probeTargets ()
313316 go ar .refreshARPTable ()
314317 ar .wg .Add (1 )
318+ ar .startingFlag .Store (false )
315319 for {
316320 select {
317321 case <- ar .quit :
@@ -325,6 +329,9 @@ func (ar *ARPSpoofer) Start() {
325329}
326330
327331func (ar * ARPSpoofer ) Stop () error {
332+ for ar .startingFlag .Load () {
333+ time .Sleep (50 * time .Millisecond )
334+ }
328335 var err error
329336 ar .logger .Info ().Msg ("[arp spoofer] Stopping..." )
330337 close (ar .quit )
Original file line number Diff line number Diff line change 11package mshark
22
3- const Version string = "mshark v0.0.11 "
3+ const Version string = "mshark v0.0.12 "
You can’t perform that action at this time.
0 commit comments