chiark / gitweb /
fixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 13:56:34 +0000 (14:56 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 13:56:34 +0000 (14:56 +0100)
hippotat/__init__.py
server

index 22c92dc..d5da7dd 100644 (file)
@@ -209,6 +209,7 @@ def queue_inbound(packet):
 class PacketQueue():
   def __init__(self, desc, max_queue_time):
     self._desc = desc
+    assert(desc + '')
     self._max_queue_time = max_queue_time
     self._pq = collections.deque() # packets
 
diff --git a/server b/server
index b9aa6f2..ab92be0 100755 (executable)
--- a/server
+++ b/server
@@ -61,7 +61,7 @@ class Client():
       limit = cfg.getint('limits',k)
       self.__dict__[k] = min(req, limit)
 
-    self._pq = PacketQueue(ip, self.max_queue_time)
+    self._pq = PacketQueue(str(ip), self.max_queue_time)
 
     if ip in clients:
       raise ValueError('multiple client cfg sections for %s' % ip)
@@ -74,6 +74,7 @@ class Client():
 
   def process_arriving_data(self, d):
     self._log(DBG.FLOW, 'req data', d=d)
+    if not len(d): return
     for packet in slip.decode(d):
       (saddr, daddr) = packet_addrs(packet)
       if saddr != self._ip:
@@ -81,11 +82,11 @@ class Client():
       route(packet, self._ip, saddr, daddr)
 
   def _req_cancel(self, request):
-    self._log(DBG.HTTPCTRL, 'cancel', idof=request)
+    self._log(DBG.HTTP_CTRL, 'cancel', idof=request)
     request.finish()
 
   def _req_error(self, err, request):
-    self._log(DBG.HTTPCTRL, 'error %s' % err, idof=request)
+    self._log(DBG.HTTP_CTRL, 'error %s' % err, idof=request)
     self._req_cancel(request)
 
   def queue_outbound(self, packet):
@@ -100,7 +101,7 @@ class Client():
     self._check_outbound()
 
   def _check_outbound(self):
-    log_debug(DBG.HTTPCTRL, 'CHKO')
+    log_debug(DBG.HTTP_CTRL, 'CHKO')
     while True:
       try: request = self._rq[0]
       except IndexError: request = None
@@ -157,7 +158,7 @@ def process_request(request, desca):
   try:
     d = request.args[b'd']
     desca['d'] = d
-  except KeyError: d = ''
+  except KeyError: d = b''
 
   cl.process_arriving_data(d)
   cl.new_request(request)