chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 23 Mar 2017 18:33:06 +0000 (18:33 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 23 Mar 2017 18:33:06 +0000 (18:33 +0000)
client
fake-userv
test.cfg

diff --git a/client b/client
index c878d72..4e0bb70 100755 (executable)
--- a/client
+++ b/client
@@ -2,6 +2,9 @@
 
 from hippotat import *
 
+import twisted.web
+import twisted.web.client
+
 client_cs = None
 
 def set_client(ci,cs,pw):
@@ -67,19 +70,20 @@ def req_ok(resp):
   resp.deliverBody(ResponseConsumer())
 
 def req_err(err):
-  print(err, >>sys.stderr)
+  print(err, file=sys.stderr)
 
 def req_fin(*args):  
-  outstanding--
+  outstanding -= 1
 
 def check_outbound():
   while True:
-    if                         outstanding >= c.max_outstanding   : break
-    if not queue.nonempty() && outstanding >= c.target_outstanding: break
+    if                          outstanding >= c.max_outstanding   : break
+    if not queue.nonempty() and outstanding >= c.target_outstanding: break
 
     d = b''
+    def moredata(s): global d; d += s
     queue.process((lambda: len(d)),
-                  (lambda s: d += s),
+                  moredata,
                   c.max_batch_up)
     assert(len(d))
     
@@ -99,10 +103,10 @@ def check_outbound():
     req = agent.request(b'POST',
                         c.url,
                         twisted.web.client.Headers(hh))
-    req.addTimeout(c.http_timeout
+    req.addTimeout(c.http_timeout)
     req.addCallbacks(req_ok, req_err)
     req.addBoth(req_fin)
-    outstanding++
+    outstanding += 1
 
 common_startup()
 process_cfg()
index 6f5da40..cf5c9f0 100755 (executable)
@@ -1,11 +1,9 @@
 #!/bin/sh
 set -e
 echo >&2 "$0: invoked as $0 $*"
-shift
-shift
 exec 3<&0 4>&1 5>&2 >&2 </dev/null
 exec xterm -T netns -e unshare -n -- sh -xc '
-  ../userv-utils.git/ipif/service \* -- "$@" <&3 >&4 2>&5 &
+  ../userv-utils.git/ipif/service "$@" <&3 >&4 2>&5 &
   sleep 0.1
   env - bash -i
 ' x "$@"
index 902f6c1..e959f7b 100644 (file)
--- a/test.cfg
+++ b/test.cfg
@@ -10,3 +10,4 @@ network = 192.0.2.0/24
 
 [192.0.2.3]
 password = sesame
+ipif = PATH=/usr/local/sbin:/sbin:/usr/sbin:$PATH really ./fake-userv /home/ian/things/Userv/userv-utils.git/ipif/service \* -- %(local)s,%(peer)s,%(mtu)s,slip '%(rnets)s'