chiark / gitweb /
hippotat: Don't set an explicit `Content-Length'.
[hippotat.git] / hippotatd
index 0482876..05c51bc 100755 (executable)
--- a/hippotatd
+++ b/hippotatd
@@ -126,7 +126,7 @@ class Client():
     nf = request.notifyFinish()
     nf.addErrback(self._req_error, request)
     nf.addCallback(self._req_fin, request, cl)
-    self._rq.append(request)
+    self._rq.append((request,nf))
     self._check_outbound()
 
   def _req_write(self, req, d):
@@ -136,9 +136,9 @@ class Client():
   def _check_outbound(self):
     log_debug(DBG.HTTP_CTRL, 'CHKO')
     while True:
-      try: request = self._rq[0]
+      try: (request,nf) = self._rq[0]
       except IndexError: request = None
-      if request and request.finished:
+      if request and nf.called:
         self._log(DBG.HTTP_CTRL, 'CHKO req finished, discard', idof=request)
         self._rq.popleft()
         continue
@@ -166,7 +166,7 @@ class Client():
       # round again, looking for more to do
 
     while len(self._rq) > self.cc.target_requests_outstanding:
-      request = self._rq.popleft()
+      (request, nf) = self._rq.popleft()
       self._log(DBG.HTTP, 'CHKO above target, returning empty', idof=request)
       request.finish()
 
@@ -174,7 +174,7 @@ def process_request(request, desca):
   # find client, update config, etc.
   metadata = request.args[b'm'][0]
   metadata = metadata.split(b'\r\n')
-  (ci_s, pw, tro, cto) = metadata[0:4]
+  (ci_s, token, tro, cto) = metadata[0:4]
   desca['m[0,2:3]'] = [ci_s, tro, cto]
   ci_s = ci_s.decode('utf-8')
   tro = int(tro); desca['tro']= tro
@@ -182,7 +182,7 @@ def process_request(request, desca):
   ci = ipaddr(ci_s)
   desca['ci'] = ci
   cl = clients[ci]
-  if pw != cl.cc.password: raise ValueError('bad password')
+  authtoken_check(cl.cc.secret, token, cl.cc.max_clock_skew)
   desca['pwok']=True
 
   if tro != cl.cc.target_requests_outstanding:
@@ -218,7 +218,7 @@ class NotStupidResource(twisted.web.resource.Resource):
   # why this is not the default is a mystery!
   def getChild(self, name, request):
     if name == b'': return self
-    else: return twisted.web.resource.Resource.getChild(name, request)
+    else: return twisted.web.resource.Resource.getChild(self, name, request)
 
 class IphttpResource(NotStupidResource):
   def render_POST(self, request):
@@ -311,6 +311,7 @@ def process_cfg(_opts, putative_servers, putative_clients):
     if not sections: continue
     cfg_process_client_limited(cc,c.server,sections, 'max_batch_down')
     cfg_process_client_limited(cc,c.server,sections, 'max_queue_time')
+    cc.max_clock_skew = cfg_search(cfg.getint, 'max_clock_skew', sections)
     Client(ci, cc)
 
   try: