chiark / gitweb /
wip config reorg
[hippotat.git] / client
diff --git a/client b/client
index a77600ec500077952a0aad5683cb0285217270f8..b60f3d177c715d6dc91be010b21428e7e51130b6 100755 (executable)
--- a/client
+++ b/client
@@ -2,27 +2,62 @@
 
 from hippotat import *
 
-defcfg = '''
-[DEFAULT]
-max_requests_outstanding = 4
+client_cs = None
 
-[virtual]
-mtu = 1500
-# [host]  } maybe computed from `network' (see server defaults)
-
-[server]
-# url     } maybe computed from `addrs' and `port' (see server defaults)
-
-# [<my ip address>]
-# password = <password>
-'''
+def set_client(ci,cs,pw):
+  global client_cs
+  global password
+  assert(client_cs is None)
+  client_cs = cs
+  c.client = ci
+  c.max_outstanding = cfg.getint(cs, 'max_requests_outstanding')
+  password = pw
 
 def process_cfg():
   global url
   global max_requests_outstanding
 
   process_cfg_common_always()
-  
+  process_cfg_server()
+
+  try:
+    c.url = cfg.get('server','url')
+  except NoOptionError:
+    process_cfg_saddrs()
+    sa = c.saddrs[0].url()
+
+  process_cfg_clients(set_client)
+
+  c.routes = cfg.get('virtual','routes')
+  c.max_queue_time = cfg.get(client_cs, 'max_queue_time')
+
+  process_cfg_ipif(client_cs,
+                   (('local', 'client'),
+                    ('peer',  'server'),
+                    ('rnets', 'routes')))
+
+outstanding = 0
+
+def start_client():
+  global queue
+  queue = PacketQueue(c.max_queue_time)
+
+def outbound(packet, saddr, daddr):
+  #print('OUT ', saddr, daddr, repr(packet))
+  queue.append(packet)
+  check_outbound()
+
+def check_outbound():
+  while True:
+    if outstanding >= c.max_outstanding: break
+    elements = { }
+    if not queue.nonempty():
+      if outstanding >= c.target_
+
+  while (outstanding <  and
+         (queue.notempty() or outstanding < c.
 
 common_startup(defcfg)
 process_cfg()
+start_ipif(c.ipif_command, outbound)
+common_run()