def __init__(self, cl, req):
super().__init__(cl, req, 'RC')
ssddesc = '[%s] %s' % (id(req), self._desc)
- self._ssd = SlipStreamDecoder(ssddesc, cl.queue_inbound)
+ self._ssd = SlipStreamDecoder(ssddesc, partial(queue_inbound, cl.ipif))
self._log(DBG.HTTP_CTRL, '__init__')
- self._success_reported = False
def dataReceived(self, data):
self._log(DBG.HTTP, 'dataReceived', d=data)
self._cl.req_fin(self._req)
except Exception as e:
self._handleexception()
- if not self._success_reported:
- log.info(cl.desc + 'running OK', dflag=False)
- self._success_reported = True
+ self._cl.report_running()
def _handleexception(self):
self._latefailure(traceback.format_exc())
cl.c = c
cl.outstanding = { }
cl.desc = '[%s %s] ' % (ss,cs)
- log.info(cl.desc + 'setting up', dflag=False)
+ cl.running_reported = False
+ cl.log_info('setting up')
+
+ def log_info(cl, msg):
+ log.info(cl.desc + msg, dflag=False)
+
+ def report_running(cl):
+ if not cl.running_reported:
+ cl.log_info('running OK')
+ cl.running_reported = True
def log(cl, dflag, msg, **kwargs):
log_debug(dflag, cl.desc + msg, **kwargs)
for cl in clients:
cl.start()
- start_ipif(cl.c.ipif_command, cl.outbound)
+ cl.ipif = start_ipif(cl.c.ipif_command, cl.outbound)
cl.check_outbound()
common_run()
status.raiseException()
def start_ipif(command, router):
- global ipif
ipif = _IpifProcessProtocol(router)
reactor.spawnProcess(ipif,
'/bin/sh',['sh','-xc', command],
childFDs={0:'w', 1:'r', 2:2},
env=None)
+ return ipif
-def queue_inbound(packet):
+def queue_inbound(ipif, packet):
log_debug(DBG.FLOW, "queue_inbound", d=packet)
ipif.transport.write(slip.delimiter)
ipif.transport.write(slip.encode(packet))
dclient.queue_outbound(packet)
elif daddr == c.vaddr or daddr not in c.vnetwork:
lt('inbound')
- queue_inbound(packet)
+ queue_inbound(ipif, packet)
elif daddr == c.relay:
lt('discard relay')
log_discard(packet, iface, saddr, daddr, 'relay')
('rnets','vnetwork')))
common_startup(process_cfg)
-start_ipif(c.ipif_command, (lambda p,s,d: route(p,"[ipif]",s,d)))
+ipif = start_ipif(c.ipif_command, (lambda p,s,d: route(p,"[ipif]",s,d)))
start_http()
common_run()