chiark / gitweb /
wip fixes
[hippotat.git] / client
diff --git a/client b/client
index 6080d4d6ae685ba30d22d62ba890a4bda773c316..074803af97ef51080f627609330b5d6d2aca82e8 100755 (executable)
--- a/client
+++ b/client
@@ -91,9 +91,9 @@ class Client():
     cl.log(DBG.CTRL_DUMP, 'OS %s' % outstanding)
 
   def start(cl):
-    cl.queue = PacketQueue('up', c.max_queue_time)
+    cl.queue = PacketQueue('up', cl.c.max_queue_time)
     cl.agent = twisted.web.client.Agent(
-      reactor, connectTimeout = c.http_timeout)
+      reactor, connectTimeout = cl.c.http_timeout)
 
   def outbound(cl, packet, saddr, daddr):
     #print('OUT ', saddr, daddr, repr(packet))
@@ -104,13 +104,13 @@ class Client():
     cl.log(DBG.HTTP_CTRL,
             'req_ok %d %s %s' % (resp.code, repr(resp.phrase), str(resp)),
             idof=req)
-  if resp.code == 200:
-    rc = ResponseConsumer(cl, req)
-  else:
-    rc = ErrorResponseConsumer(cl, req, resp)
+    if resp.code == 200:
+      rc = ResponseConsumer(cl, req)
+    else:
+      rc = ErrorResponseConsumer(cl, req, resp)
 
-  resp.deliverBody(rc)
-  # now rc is responsible for calling req_fin
+    resp.deliverBody(rc)
+    # now rc is responsible for calling req_fin
 
   def req_err(cl, req, err):
     # called when the Deferred fails, or (if it completes),
@@ -124,7 +124,7 @@ class Client():
         raise RuntimeError('[%#x] previously %s' % (id(req), outstanding[req]))
       cl.outstanding[req] = err
       cl.log_outstanding()
-      reactor.callLater(c.http_retry, partial(cl.req_fin, req))
+      reactor.callLater(cl.c.http_retry, partial(cl.req_fin, req))
     except Exception as e:
       crash(traceback.format_exc() + '\n----- handling -----\n' + err)
 
@@ -205,7 +205,7 @@ def process_cfg(putative_servers, putative_clients):
     for (ci,cs) in putative_clients.items():
       c = ConfigResults()
 
-      sections = process_cfg_client_common(c,ss,cs,ci):
+      sections = cfg_process_client_common(c,ss,cs,ci)
       if not sections: continue
 
       def srch(getter,key): return cfg_search(getter,key,sections)
@@ -216,13 +216,16 @@ def process_cfg(putative_servers, putative_clients):
       c.http_retry      = srch(cfg.getint, 'http_retry')
       c.vroutes         = srch(cfg.get,    'vroutes')
 
-      process_cfg_common(c,ss)
       try: c.url = srch(cfg.get,'url')
       except NoOptionError:
-        process_cfg_saddrs()
+        cfg_process_saddrs(c, ss)
         c.url = c.saddrs[0].url()
 
-      process_cfg_ipif(cc,
+      c.client = ci
+
+      cfg_process_vaddr(c,ss)
+
+      cfg_process_ipif(c,
                        sections,
                        (('local','client'),
                         ('peer', 'vaddr'),