fixed timer context

This commit is contained in:
anoduck 2024-01-26 13:24:16 -05:00
parent 1fedcae279
commit 5716d1c438

View file

@ -220,7 +220,8 @@ class Purge(object):
def __getitem__(self, pkt):
return pkt
def do_hop(self, mon_if, ichan) -> None:
def do_hop(self, mon_if, chans) -> None:
ichan = choice(chans)
log.debug('Hopping on: {0}'.format(ichan))
os.system(f'iw dev {self.mon_if} set channel {str(ichan)}')
log.debug('Channel set to {0}'.format(ichan))
@ -236,12 +237,11 @@ class Purge(object):
log.info('Channel list: {0}'.format(chlist))
thread = threading.current_thread()
print(f'name={thread.name}, daemon={thread.daemon}')
timer = threading.Timer(14.7, self.do_hop,
args=(mon_if, chans))
while True:
with lock:
ichan = choice(chans)
with threading.Timer(14.7, self.do_hop,
args=(mon_if, ichan)) as timer:
timer.start()
timer.start()
def send_pkt(self, bssid) -> None:
self.bssid = bssid