chiark / gitweb /
move ipif slip process handling
[hippotat.git] / server
diff --git a/server b/server
index 6650073ac4e54f532a0dc481c70b63914e8d8210..80bdd807202cdd8a20f09eb1a5a1cc431dd4202d 100755 (executable)
--- a/server
+++ b/server
@@ -24,7 +24,7 @@ import collections
 
 import syslog
 
-from hippotit import *
+from hippotat import *
 
 clients = { }
 
@@ -88,36 +88,6 @@ def log_discard(packet, saddr, daddr, why):
 #  syslog.syslog(syslog.LOG_DEBUG,
 #                'discarded packet %s -> %s (%s)' % (saddr, daddr, why))
 
-#---------- ipif (slip subprocess) ----------
-
-class IpifProcessProtocol(twisted.internet.protocol.ProcessProtocol):
-  def __init__(self):
-    self._buffer = b''
-  def connectionMade(self): pass
-  def outReceived(self, data):
-    #print('RECV ', repr(data))
-    self._buffer += data
-    packets = slip.decode(self._buffer)
-    self._buffer = packets.pop()
-    for packet in packets:
-      if not len(packet): continue
-      (saddr, daddr) = packet_addrs(packet)
-      route(packet, saddr, daddr)
-  def processEnded(self, status):
-    status.raiseException()
-
-def start_ipif():
-  global ipif
-  ipif = IpifProcessProtocol()
-  reactor.spawnProcess(ipif,
-                       '/bin/sh',['sh','-xc', ipif_command],
-                       childFDs={0:'w', 1:'r', 2:2})
-
-def queue_inbound(packet):
-  ipif.transport.write(slip.delimiter)
-  ipif.transport.write(slip.encode(packet))
-  ipif.transport.write(slip.delimiter)
-
 #---------- client ----------
 
 class Client():
@@ -229,7 +199,7 @@ class IphttpResource(twisted.web.resource.Resource):
     c.new_request(request)
 
   def render_GET(self, request):
-    return b'<html><body>hippotit</body></html>'
+    return b'<html><body>hippotat</body></html>'
 
 def start_http():
   resource = IphttpResource()
@@ -304,7 +274,7 @@ def startup():
   cfg.read(opts.configfile)
   process_cfg()
 
-  start_ipif()
+  start_ipif(ipif_command, route)
   start_http()
 
 startup()