chiark / gitweb /
wip, client does something
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 21 Mar 2017 21:01:07 +0000 (21:01 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 21 Mar 2017 21:01:07 +0000 (21:01 +0000)
client
hippotat/__init__.py
server
test.cfg

diff --git a/client b/client
index b355647..7684cf3 100755 (executable)
--- a/client
+++ b/client
@@ -8,21 +8,24 @@ max_requests_outstanding = 4
 
 [virtual]
 mtu = 1500
-# [server]  } maybe computed from `network' (see server defaults)
+# [server]  # maybe computed from `network' (see server defaults)
+# [routes]  # default is none
 
 [server]
-# url     } maybe computed from `addrs' and `port' (see server defaults)
+# url     # maybe computed from `addrs' and `port' (see server defaults)
 
 # [<my ip address>]
 # password = <password>
 '''
 
-c.clientv = None
+client_cs = None
 
 def set_client(ci,cs,pw):
+  global client_cs
   global password
-  assert(c.clientv is None)
-  c.clientv = ci
+  assert(client_cs is None)
+  client_cs = cs
+  c.client = ci
   c.max_outstanding = cfg.getint(cs, 'max_requests_outstanding')
   password = pw
 
@@ -41,5 +44,21 @@ def process_cfg():
 
   process_cfg_clients(set_client)
 
+  try:
+    c.routes = cfg.get('virtual','routes')
+  except NoOptionError:
+    c.routes = ''
+
+  process_cfg_ipif(client_cs,
+                   (('local', 'client'),
+                    ('peer',  'server'),
+                    ('rnets', 'routes')))
+
+def outbound(packet, saddr, daddr):
+  print('OUT ', saddr, daddr, repr(packet))
+  pass
+
 common_startup(defcfg)
 process_cfg()
+start_ipif(c.ipif_command, outbound)
+common_run()
index 194dc99..1baaed3 100644 (file)
@@ -73,7 +73,7 @@ class _IpifProcessProtocol(twisted.internet.protocol.ProcessProtocol):
     self._router = router
   def connectionMade(self): pass
   def outReceived(self, data):
-    #print('RECV ', repr(data))
+    #print('IPIF-GOT ', repr(data))
     self._buffer += data
     packets = slip.decode(self._buffer)
     self._buffer = packets.pop()
@@ -148,7 +148,7 @@ def process_cfg_common_always():
 def process_cfg_ipif(section, varmap):
   for d, s in varmap:
     try: v = getattr(c, s)
-    except KeyError: pass
+    except AttributeError: continue
     setattr(c, d, v)
 
   print(repr(c))
diff --git a/server b/server
index 6da5be4..0bbac6d 100755 (executable)
--- a/server
+++ b/server
@@ -212,7 +212,7 @@ def process_cfg():
 
   process_cfg_ipif('server',
                    (('local','server'),
-                    ('peer','relay'),
+                    ('peer', 'relay'),
                     ('rnets','network')))
 
 common_startup(defcfg)
index ce2d858..ba1b09a 100644 (file)
--- a/test.cfg
+++ b/test.cfg
@@ -1,6 +1,8 @@
+[DEFAULT]
+ipif = PATH=/usr/local/sbin:/sbin:/usr/sbin:$PATH really /home/ian/things/Userv/userv-utils.git/ipif/service \* -- %(local)s,%(peer)s,%(mtu)s,slip '%(rnets)s'
+
 [server]
 addrs = 127.0.0.1
-ipif = PATH=/usr/local/sbin:/sbin:/usr/sbin:$PATH really /home/ian/things/Userv/userv-utils.git/ipif/service \* -- %(local)s,%(relay)s,%(mtu)s,slip %(network)s
 
 [virtual]
 network = 192.0.2.0/24