def worker_multiplexer(queue_multiplexer, queue_notifier): global shutdown def debug(*args, **kwargs): print(args, kwargs) multiplexer = Multiplexer(queue_notifier) while not shutdown: pycmd = queue_multiplexer.get() getattr(multiplexer, pycmd["command"], debug)(*pycmd["args"]) if pycmd['command'] == 'buried_all': break multiplexer.stop()
def __init__(self): self.dns = dnssrv.Handler() self.dhcp = dhcpsrv.Handler() self.mul = Multiplexer( DnsUdpServer(("", int(getenv("DNSPORT", 5353))), self.dns), DhcpUdpServer(("", int(getenv("DHCPPORT", 6767))), self.dhcp), ) self.dns.add_middleware(GoogleDnsHandler(), dnssrv.PRIO_LOWEST)
def worker_multiplexer(queue_multiplexer, queue_notifier): global shutdown def debug(*args, **kwargs): print(args, kwargs) multiplexer = Multiplexer(queue_notifier) while not shutdown: pycmd = queue_multiplexer.get() getattr(multiplexer, pycmd["command"], debug)(*pycmd["args"])
class DhcpNameserver: def __init__(self): self.dns = dnssrv.Handler() self.dhcp = dhcpsrv.Handler() self.mul = Multiplexer( DnsUdpServer(("", int(getenv("DNSPORT", 5353))), self.dns), DhcpUdpServer(("", int(getenv("DHCPPORT", 6767))), self.dhcp), ) self.dns.add_middleware(GoogleDnsHandler(), dnssrv.PRIO_LOWEST) def start(self): self.mul.start() def stop(self): self.mul.stop() def push(self, handler): if isinstance(handler, dnssrv.middlewares.Middleware): self.dns.add_middleware(handler) if isinstance(handler, dhcpsrv.middlewares.Middleware): self.dhcp.add_middleware(handler)
logging.basicConfig(filename=os.path.join(LOG_FOLDER, DATE_FILENAME + '.log'), level=logging.INFO) logging.info('start mppmon') #store_iv_curve(iv_curve_sample.curve, z.number_to_words(5), datetime.datetime.now()) try: t = bkload.IvTracer(private.COMPORT) except Exception, e: print(e) logging.error(e) raise SystemExit(0) try: mp = Multiplexer() mp.ChannelsOff() except Exception, e: print(e) logging.error(e) raise SystemExit(0) for k in cfg.sweep_settings.keys(): p = cfg.sweep_settings[k] if p['enabled']: mp.SelectChannel(p['channel']) d = t.measure_iv(p['points'], p['sweeptime'] / p['points']) store_iv_curve(d, z.number_to_words(p['channel'] + 1), datetime.datetime.now())