renamed chan_hop to do_hop

This commit is contained in:
anoduck 2024-01-26 13:19:36 -05:00
parent 757fa0b5fd
commit 1fedcae279
2 changed files with 3 additions and 43 deletions

View file

@ -220,7 +220,7 @@ class Purge(object):
def __getitem__(self, pkt):
return pkt
def chan_hop(self, mon_if, ichan) -> None:
def do_hop(self, mon_if, ichan) -> None:
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))
@ -239,7 +239,8 @@ class Purge(object):
while True:
with lock:
ichan = choice(chans)
with threading.Timer(14.7, chan_hop, args=(mon_if, ichan)) as timer:
with threading.Timer(14.7, self.do_hop,
args=(mon_if, ichan)) as timer:
timer.start()
def send_pkt(self, bssid) -> None:

View file

@ -1,41 +0,0 @@
# -*- coding: utf-8 -*-
# SuperFastPython.com
# example of a long-running daemon thread
from time import sleep
from random import random
from threading import Thread
# long-running background task
def background_task():
global data
# record the last seen value
last_seen = data
# run forever
while True:
# check for change
if data != last_seen:
# report the change
print(f'Monitor: data has changed to {data}')
# update last seen
last_seen = data
# block for a while
sleep(0.1)
# global data
data = 0
# create and start the daemon thread
print('Starting background task...')
daemon = Thread(target=background_task, daemon=True, name='Monitor')
daemon.start()
# main thread is carrying on...
print('Main thread is carrying on...')
for _ in range(5):
# block for a while
value = random() * 5
sleep(value)
# update the data variable
data = value
print('Main thread done.')