chiark / gitweb /
wip
[hippotat] / client
... / ...
CommitLineData
1#!/usr/bin/python3
2
3from hippotat import *
4
5client_cs = None
6
7def set_client(ci,cs,pw):
8 global client_cs
9 global password
10 assert(client_cs is None)
11 client_cs = cs
12 c.client = ci
13 c.max_outstanding = cfg.getint(cs, 'max_requests_outstanding')
14 password = pw
15
16def process_cfg():
17 global url
18 global max_requests_outstanding
19
20 process_cfg_common_always()
21 process_cfg_server()
22
23 try:
24 c.url = cfg.get('server','url')
25 except NoOptionError:
26 process_cfg_saddrs()
27 sa = c.saddrs[0].url()
28
29 process_cfg_clients(set_client)
30
31 c.routes = cfg.get('virtual','routes')
32 c.max_queue_time = cfg.get(client_cs, 'max_queue_time')
33
34 process_cfg_ipif(client_cs,
35 (('local', 'client'),
36 ('peer', 'server'),
37 ('rnets', 'routes')))
38
39outstanding = 0
40
41def start_client():
42 global queue
43 queue = PacketQueue(c.max_queue_time)
44
45def outbound(packet, saddr, daddr):
46 #print('OUT ', saddr, daddr, repr(packet))
47 queue.append(packet)
48 check_outbound()
49
50def check_outbound():
51 while True:
52 if outstanding >= c.max_outstanding: break
53 elements = { }
54 if not queue.nonempty():
55 if outstanding >= c.target_
56
57 while (outstanding < and
58 (queue.notempty() or outstanding < c.
59
60common_startup()
61process_cfg()
62start_ipif(c.ipif_command, outbound)
63common_run()