From c0c90673b8858c021e95453ce017397db5242c75 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 23 Mar 2017 18:33:06 +0000 Subject: [PATCH] wip --- client | 18 +++++++++++------- fake-userv | 4 +--- test.cfg | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/client b/client index c878d72..4e0bb70 100755 --- 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() diff --git a/fake-userv b/fake-userv index 6f5da40..cf5c9f0 100755 --- a/fake-userv +++ b/fake-userv @@ -1,11 +1,9 @@ #!/bin/sh set -e echo >&2 "$0: invoked as $0 $*" -shift -shift exec 3<&0 4>&1 5>&2 >&2 &4 2>&5 & + ../userv-utils.git/ipif/service "$@" <&3 >&4 2>&5 & sleep 0.1 env - bash -i ' x "$@" diff --git a/test.cfg b/test.cfg index 902f6c1..e959f7b 100644 --- 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' -- 2.30.2