48b635a9d2f62c19a2f2489f66d2a43a70bc0b54
7 def set_client(ci
,cs
,pw
):
10 assert(client_cs
is None)
13 c
.max_outstanding
= cfg
.getint(cs
, 'max_requests_outstanding')
14 c
.target_outstanding
= cfg
.getint(cs
, 'target_requests_outstanding')
19 global max_requests_outstanding
21 process_cfg_common_always()
25 c
.url
= cfg
.get('server','url')
28 sa
= c
.saddrs
[0].url()
30 process_cfg_clients(set_client
)
32 c
.routes
= cfg
.get('virtual','routes')
33 c
.max_queue_time
= cfg
.getint(client_cs
, 'max_queue_time')
34 c
.max_batch_up
= cfg
.getint(client_cs
, 'max_batch_up')
36 process_cfg_ipif(client_cs
,
46 queue
= PacketQueue(c
.max_queue_time
)
47 agent
= twisted
.web
.client
.Agent(reactor
, connectTimeout
= c
.http_timeout
)
49 def outbound(packet
, saddr
, daddr
):
50 #print('OUT ', saddr, daddr, repr(packet))
58 print(err
, >>sys
.stderr
)
65 if outstanding
>= c
.max_outstanding
: break
66 if not queue
.nonempty() && outstanding
>= c
.target_outstanding
: break
69 queue
.process((lambda: len(d
)),
75 mime
= (b
'--b' + crlf
+
76 b
'Content-Disposition: form-data; name="m"' + crlf
+
79 c
.target_outstanding
+ crlf
+
81 b
'Content-Disposition: form-data; name="d"' + crlf
+
82 mime_translate(d
) + crlf
+
85 hh
= { 'User-Agent': ['hippotat'],
86 'Content-Type': ['multipart/form-data; boundary="b"'] }
87 req
= agent
.request(b
'POST',
89 twisted
.web
.client
.Headers(hh
))
90 req
.addTimeout(c
.http_timeout
,
91 req
.addCallbacks(req_ok
, req_err
)
98 start_ipif(c
.ipif_command
, outbound
)