+import time
+import codecs
+
+import re as regexp
+
+import hippotat.slip as slip
+
+class DBG(twisted.python.constants.Names):
+ ROUTE = NamedConstant()
+ DROP = NamedConstant()
+ FLOW = NamedConstant()
+ HTTP = NamedConstant()
+ HTTP_CTRL = NamedConstant()
+ INIT = NamedConstant()
+ QUEUE = NamedConstant()
+ QUEUE_CTRL = NamedConstant()
+ HTTP_FULL = NamedConstant()
+
+_hex_codec = codecs.getencoder('hex_codec')
+
+log = twisted.logger.Logger()
+
+def log_debug(dflag, msg, idof=None, d=None):
+ #print('---------------->',repr((dflag, msg, idof, d)), file=sys.stderr)
+ if idof is not None:
+ msg = '[%d] %s' % (id(idof), msg)
+ if d is not None:
+ #d = d[0:64]
+ d = _hex_codec(d)[0].decode('ascii')
+ msg += ' ' + d
+ log.info('{dflag} {msgcore}', dflag=dflag, msgcore=msg)
+
+defcfg = '''
+[DEFAULT]
+#[<client>] overrides
+max_batch_down = 65536 # used by server, subject to [limits]
+max_queue_time = 10 # used by server, subject to [limits]
+max_request_time = 54 # used by server, subject to [limits]
+target_requests_outstanding = 3 # must match; subject to [limits] on server
+max_requests_outstanding = 4 # used by client
+max_batch_up = 4000 # used by client
+http_timeout = 30 # used by client
+http_retry = 5 # used by client
+
+#[server] or [<client>] overrides
+ipif = userv root ipif %(local)s,%(peer)s,%(mtu)s,slip %(rnets)s
+# extra interpolations: %(local)s %(peer)s %(rnet)s
+# obtained on server [virtual]server [virtual]relay [virtual]network
+# from on client <client> [virtual]server [virtual]routes
+
+[virtual]
+mtu = 1500
+routes = ''
+# network = <prefix>/<len> # mandatory for server
+# server = <ipaddr> # used by both, default is computed from `network'
+# relay = <ipaddr> # used by server, default from `network' and `server'
+# default server is first host in network
+# default relay is first host which is not server
+
+[server]
+# addrs = 127.0.0.1 ::1 # mandatory for server
+port = 80 # used by server
+# url # used by client; default from first `addrs' and `port'
+
+# [<client-ip4-or-ipv6-address>]
+# password = <password> # used by both, must match
+
+[limits]
+max_batch_down = 262144 # used by server
+max_queue_time = 121 # used by server
+max_request_time = 121 # used by server
+target_requests_outstanding = 10 # used by server
+'''