From: Ian Jackson Date: Tue, 18 Jun 2019 17:40:29 +0000 (+0100) Subject: mtu: Add mtu parameter to SlipStreamDecoder and start_ipif X-Git-Tag: hippotat/1.0.0~55^2~2 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=5407334f0fd09ff6baf36683b410fd04626232e1;p=hippotat.git mtu: Add mtu parameter to SlipStreamDecoder and start_ipif These don't take a config, so we must pass this as a parameter. Change all call sites. Not used yet so no functional change. Signed-off-by: Ian Jackson --- diff --git a/hippotat b/hippotat index 6aa3121..d7a4daa 100755 --- a/hippotat +++ b/hippotat @@ -55,7 +55,8 @@ class ResponseConsumer(GeneralResponseConsumer): def __init__(self, cl, req, resp): super().__init__(cl, req, resp, 'RC') ssddesc = '[%s] %s' % (id(req), self._desc) - self._ssd = SlipStreamDecoder(ssddesc, partial(queue_inbound, cl.ipif)) + self._ssd = SlipStreamDecoder(ssddesc, partial(queue_inbound, cl.ipif), + cl.c.mtu) self._log(DBG.HTTP_CTRL, '__init__') def dataReceived(self, data): @@ -302,7 +303,7 @@ common_startup(process_cfg) for cl in clients: cl.start() - cl.ipif = start_ipif(cl.c.ipif_command, cl.outbound) + cl.ipif = start_ipif(cl.c.ipif_command, cl.outbound, cl.c.mtu) cl.check_outbound() common_run() diff --git a/hippotatd b/hippotatd index 05c51bc..e5e01e2 100755 --- a/hippotatd +++ b/hippotatd @@ -475,5 +475,7 @@ common_startup(process_cfg) catch_termination() start_http() daemonise() -ipif = 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)), + c.mtu) common_run() diff --git a/hippotatlib/__init__.py b/hippotatlib/__init__.py index 6c60eef..6423ba3 100644 --- a/hippotatlib/__init__.py +++ b/hippotatlib/__init__.py @@ -228,7 +228,7 @@ def ipnetwork(input): #---------- ipif (SLIP) subprocess ---------- class SlipStreamDecoder(): - def __init__(self, desc, on_packet): + def __init__(self, desc, on_packet, mtu): self._buffer = b'' self._on_packet = on_packet self._desc = desc @@ -261,9 +261,9 @@ class SlipStreamDecoder(): self._maybe_packet(packets[0]) class _IpifProcessProtocol(twisted.internet.protocol.ProcessProtocol): - def __init__(self, router): + def __init__(self, router, mtu): self._router = router - self._decoder = SlipStreamDecoder('ipif', self.slip_on_packet) + self._decoder = SlipStreamDecoder('ipif', self.slip_on_packet, mtu) def connectionMade(self): pass def outReceived(self, data): self._decoder.inputdata(data) @@ -276,8 +276,8 @@ class _IpifProcessProtocol(twisted.internet.protocol.ProcessProtocol): def processEnded(self, status): status.raiseException() -def start_ipif(command, router): - ipif = _IpifProcessProtocol(router) +def start_ipif(command, router, mtu): + ipif = _IpifProcessProtocol(router, mtu) reactor.spawnProcess(ipif, '/bin/sh',['sh','-xc', command], childFDs={0:'w', 1:'r', 2:2},