chiark / gitweb /
49a10efecf0b7dd81cca7c6de293ce88d2dae16f
[hippotat.git] / client
1 #!/usr/bin/python3
2
3 from hippotat import *
4
5 client_cs = None
6
7 def 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
16 def 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
39 outstanding = 0
40
41 def start_client():
42   global queue
43   queue = PacketQueue(c.max_queue_time)
44
45 def outbound(packet, saddr, daddr):
46   #print('OUT ', saddr, daddr, repr(packet))
47   queue.append(packet)
48   check_outbound()
49
50 def 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
60 common_startup()
61 process_cfg()
62 start_ipif(c.ipif_command, outbound)
63 common_run()