c.url = cfg.get('server','url')
except NoOptionError:
process_cfg_saddrs()
- sa = c.saddrs[0].url()
+ c.url = c.saddrs[0].url()
process_cfg_clients(set_client)
def req_err(err):
print(err, file=sys.stderr)
-def req_fin(*args):
+def req_fin(*args):
+ global outstanding
outstanding -= 1
def check_outbound():
+ global outstanding
while True:
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
+ def moredata(s): nonlocal d; d += s
queue.process((lambda: len(d)),
moredata,
c.max_batch_up)
- assert(len(d))
crlf = b'\r\n'
mime = (b'--b' + crlf +
b'Content-Disposition: form-data; name="m"' + crlf +
password + crlf +
- c.client + crlf +
- c.target_outstanding + crlf +
+ str(c.client) .encode('ascii') + crlf +
+ str(c.target_outstanding) .encode('ascii') + crlf +
b'--b' + crlf +
b'Content-Disposition: form-data; name="d"' + crlf +
mime_translate(d) + crlf +
req = agent.request(b'POST',
c.url,
twisted.web.client.Headers(hh))
- req.addTimeout(c.http_timeout)
+ req.addTimeout(c.http_timeout, reactor)
req.addCallbacks(req_ok, req_err)
req.addBoth(req_fin)
outstanding += 1
exec xterm -T netns -e unshare -n -- sh -xc '
"$@" <&3 >&4 2>&5 &
sleep 0.1
+ ping 192.0.2.1 &
env - bash -i
' x "$@"
from configparser import NoOptionError
import collections
+import time
import re as regexp
except IndexError: return False
age = time.monotonic() - queuetime
- if age > self.max_queue_time:
+ if age > self._max_queue_time:
# strip old packets off the front
self._pq.popleft()
continue
moredata(slip.delimiter)
moredata(encoded)
- self._pq.popLeft()
+ self._pq.popleft()
#---------- error handling ----------
try:
self.addr = ipaddress.IPv4Address(addrspec)
self._endpointfactory = twisted.internet.endpoints.TCP4ServerEndpoint
- self._inurl = '%s'
+ self._inurl = b'%s'
except AddressValueError:
self.addr = ipaddress.IPv6Address(addrspec)
self._endpointfactory = twisted.internet.endpoints.TCP6ServerEndpoint
- self._inurl = '[%s]'
+ self._inurl = b'[%s]'
def make_endpoint(self):
return self._endpointfactory(reactor, self.port, self.addr)
def url(self):
- url = 'http://' + (self._inurl % self.addr)
- if self.port != 80: url += ':%d' % self.port
- url += '/'
+ url = b'http://' + (self._inurl % str(self.addr).encode('ascii'))
+ if self.port != 80: url += b':%d' % self.port
+ url += b'/'
return url
def process_cfg_saddrs():
if not (':' in cs or '.' in cs): continue
ci = ipaddr(cs)
pw = cfg.get(cs, 'password')
+ pw = pw.encode('utf-8')
constructor(ci,cs,pw)
#---------- startup ----------
def route(packet, saddr, daddr):
print('TRACE ', saddr, daddr, packet)
- try: client = clients[daddr]
+ try: dclient = clients[daddr]
except KeyError: dclient = None
if dclient is not None:
dclient.queue_outbound(packet)
self.max_batch_down)
assert(request.sentLength)
- self._rq.popLeft()
+ self._rq.popleft()
request.finish()
# round again, looking for more to do