Commit | Line | Data |
---|---|---|
094ee3a2 | 1 | #!/usr/bin/python3 |
0256fc10 IJ |
2 | # |
3 | # Hippotat - Asinine IP Over HTTP program | |
4 | # ./hippotatd - server main program | |
5 | # | |
6 | # Copyright 2017 Ian Jackson | |
7 | # | |
f85d143f | 8 | # AGPLv3+ + CAFv2+ |
0256fc10 | 9 | # |
f85d143f IJ |
10 | # This program is free software: you can redistribute it and/or |
11 | # modify it under the terms of the GNU Affero General Public | |
12 | # License as published by the Free Software Foundation, either | |
13 | # version 3 of the License, or (at your option) any later version, | |
14 | # with the "CAF Login Exception" as published by Ian Jackson | |
15 | # (version 2, or at your option any later version) as an Additional | |
16 | # Permission. | |
0256fc10 | 17 | # |
f85d143f IJ |
18 | # This program is distributed in the hope that it will be useful, |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | # Affero General Public License for more details. | |
22 | # | |
23 | # You should have received a copy of the GNU Affero General Public | |
24 | # License and the CAF Login Exception along with this program, in | |
25 | # the file AGPLv3+CAFv2. If not, email Ian Jackson | |
26 | # <ijackson@chiark.greenend.org.uk>. | |
0256fc10 | 27 | |
1d33eef3 | 28 | #@ import sys; sys.path.append('@PYBUILD_INSTALL_DIR@') |
5a37bac8 | 29 | from hippotatlib import * |
aa663282 | 30 | |
e2d41dc1 | 31 | import os |
4a780703 IJ |
32 | import tempfile |
33 | import atexit | |
34 | import shutil | |
d84dbf4b | 35 | import subprocess |
e2d41dc1 | 36 | |
e2d41dc1 | 37 | import twisted.internet |
e2d41dc1 | 38 | from twisted.web.server import NOT_DONE_YET |
e2d41dc1 | 39 | |
99e6411f IJ |
40 | import twisted.web.static |
41 | ||
4a780703 IJ |
42 | import hippotatlib.ownsource |
43 | from hippotatlib.ownsource import SourceShipmentPreparer | |
44 | ||
5da7763e IJ |
45 | #import twisted.web.server import Site |
46 | #from twisted.web.resource import Resource | |
3fba9787 | 47 | |
c4b6d990 IJ |
48 | import syslog |
49 | ||
4a780703 IJ |
50 | cleanups = [ ] |
51 | ||
b0cfbfce | 52 | clients = { } |
3fba9787 | 53 | |
5da7763e IJ |
54 | #---------- "router" ---------- |
55 | ||
a8827d59 | 56 | def route(packet, iface, saddr, daddr): |
d579a048 | 57 | def lt(dest): |
8c3b6620 | 58 | log_debug(DBG.ROUTE, 'route: %s -> %s: %s' % (saddr,daddr,dest), d=packet) |
84e763c7 | 59 | try: dclient = clients[daddr] |
5da7763e IJ |
60 | except KeyError: dclient = None |
61 | if dclient is not None: | |
d579a048 | 62 | lt('client') |
5da7763e | 63 | dclient.queue_outbound(packet) |
8d374606 | 64 | elif daddr == c.vaddr or daddr not in c.vnetwork: |
d579a048 | 65 | lt('inbound') |
909e0ff3 | 66 | queue_inbound(ipif, packet) |
d96f4d70 | 67 | elif daddr == c.vrelay: |
d579a048 | 68 | lt('discard relay') |
a8827d59 | 69 | log_discard(packet, iface, saddr, daddr, 'relay') |
5da7763e | 70 | else: |
d579a048 | 71 | lt('discard no-client') |
a8827d59 | 72 | log_discard(packet, iface, saddr, daddr, 'no-client') |
5da7763e | 73 | |
5da7763e | 74 | #---------- client ---------- |
c4b6d990 | 75 | |
ec88b1f1 | 76 | class Client(): |
8d374606 | 77 | def __init__(self, ip, cc): |
ec88b1f1 IJ |
78 | # instance data members |
79 | self._ip = ip | |
8d374606 | 80 | self.cc = cc |
0ac316c8 | 81 | self._rq = collections.deque() # requests |
74934d63 | 82 | self._pq = PacketQueue(str(ip), self.cc.max_queue_time) |
88487243 | 83 | |
8d374606 | 84 | if ip not in c.vnetwork: |
c7f134ce | 85 | raise ValueError('client %s not in vnetwork' % ip) |
88487243 | 86 | |
88487243 IJ |
87 | if ip in clients: |
88 | raise ValueError('multiple client cfg sections for %s' % ip) | |
89 | clients[ip] = self | |
90 | ||
8c3b6620 IJ |
91 | self._log(DBG.INIT, 'new') |
92 | ||
b68c0739 IJ |
93 | def _log(self, dflag, msg, **kwargs): |
94 | log_debug(dflag, ('client %s: ' % self._ip)+msg, **kwargs) | |
d579a048 | 95 | |
88487243 | 96 | def process_arriving_data(self, d): |
e8fcf3b7 | 97 | self._log(DBG.FLOW, "req data (enc'd)", d=d) |
8718b02c | 98 | if not len(d): return |
88487243 IJ |
99 | for packet in slip.decode(d): |
100 | (saddr, daddr) = packet_addrs(packet) | |
101 | if saddr != self._ip: | |
102 | raise ValueError('wrong source address %s' % saddr) | |
a8827d59 | 103 | route(packet, self._ip, saddr, daddr) |
88487243 IJ |
104 | |
105 | def _req_cancel(self, request): | |
8718b02c | 106 | self._log(DBG.HTTP_CTRL, 'cancel', idof=request) |
b6c0b1bb IJ |
107 | try: request.finish() |
108 | except Exception: pass | |
88487243 IJ |
109 | |
110 | def _req_error(self, err, request): | |
8718b02c | 111 | self._log(DBG.HTTP_CTRL, 'error %s' % err, idof=request) |
88487243 IJ |
112 | self._req_cancel(request) |
113 | ||
114 | def queue_outbound(self, packet): | |
115 | self._pq.append(packet) | |
ca732796 | 116 | self._check_outbound() |
88487243 | 117 | |
7432045d IJ |
118 | def _req_fin(self, dummy, request, cl): |
119 | self._log(DBG.HTTP_CTRL, '_req_fin ' + repr(dummy), idof=request) | |
120 | try: cl.cancel() | |
121 | except twisted.internet.error.AlreadyCalled: pass | |
122 | ||
d579a048 | 123 | def new_request(self, request): |
88487243 | 124 | request.setHeader('Content-Type','application/octet-stream') |
74934d63 | 125 | cl = reactor.callLater(self.cc.http_timeout, self._req_cancel, request) |
7432045d IJ |
126 | nf = request.notifyFinish() |
127 | nf.addErrback(self._req_error, request) | |
128 | nf.addCallback(self._req_fin, request, cl) | |
969a1fca | 129 | self._rq.append((request,nf)) |
88487243 IJ |
130 | self._check_outbound() |
131 | ||
3d003cdd IJ |
132 | def _req_write(self, req, d): |
133 | self._log(DBG.HTTP, 'req_write ', idof=req, d=d) | |
134 | req.write(d) | |
135 | ||
88487243 | 136 | def _check_outbound(self): |
8718b02c | 137 | log_debug(DBG.HTTP_CTRL, 'CHKO') |
88487243 | 138 | while True: |
969a1fca | 139 | try: (request,nf) = self._rq[0] |
88487243 | 140 | except IndexError: request = None |
969a1fca | 141 | if request and nf.called: |
8c3b6620 | 142 | self._log(DBG.HTTP_CTRL, 'CHKO req finished, discard', idof=request) |
88487243 IJ |
143 | self._rq.popleft() |
144 | continue | |
145 | ||
146 | if not self._pq.nonempty(): | |
147 | # no packets, oh well | |
8c3b6620 | 148 | self._log(DBG.HTTP_CTRL, 'CHKO no packets, OUT-DONE', idof=request) |
d579a048 | 149 | break |
88487243 IJ |
150 | |
151 | if request is None: | |
152 | # no request | |
8c3b6620 | 153 | self._log(DBG.HTTP_CTRL, 'CHKO no request, OUT-DONE', idof=request) |
88487243 IJ |
154 | break |
155 | ||
8c3b6620 | 156 | self._log(DBG.HTTP_CTRL, 'CHKO processing', idof=request) |
88487243 | 157 | # request, and also some non-expired packets |
7b07f0b5 | 158 | self._pq.process((lambda: request.sentLength), |
3d003cdd | 159 | (lambda d: self._req_write(request, d)), |
74934d63 | 160 | self.cc.max_batch_down) |
0ac316c8 | 161 | |
88487243 | 162 | assert(request.sentLength) |
84e763c7 | 163 | self._rq.popleft() |
88487243 | 164 | request.finish() |
8c3b6620 | 165 | self._log(DBG.HTTP, 'complete', idof=request) |
88487243 | 166 | # round again, looking for more to do |
0ac316c8 | 167 | |
74934d63 | 168 | while len(self._rq) > self.cc.target_requests_outstanding: |
969a1fca | 169 | (request, nf) = self._rq.popleft() |
8c3b6620 | 170 | self._log(DBG.HTTP, 'CHKO above target, returning empty', idof=request) |
88487243 | 171 | request.finish() |
650a3251 | 172 | |
d579a048 | 173 | def process_request(request, desca): |
a4e03162 | 174 | # find client, update config, etc. |
5dd3275b | 175 | metadata = request.args[b'm'][0] |
00192d6a | 176 | metadata = metadata.split(b'\r\n') |
ef041033 | 177 | (ci_s, token, tro, cto) = metadata[0:4] |
ba5630fd | 178 | desca['m[0,2:3]'] = [ci_s, tro, cto] |
a9a369c7 | 179 | ci_s = ci_s.decode('utf-8') |
ba5630fd IJ |
180 | tro = int(tro); desca['tro']= tro |
181 | cto = int(cto); desca['cto']= cto | |
a4e03162 | 182 | ci = ipaddr(ci_s) |
d579a048 | 183 | desca['ci'] = ci |
a4e03162 | 184 | cl = clients[ci] |
ef041033 | 185 | authtoken_check(cl.cc.secret, token, cl.cc.max_clock_skew) |
b68c0739 | 186 | desca['pwok']=True |
1672ded0 | 187 | |
74934d63 IJ |
188 | if tro != cl.cc.target_requests_outstanding: |
189 | raise ValueError('tro must be %d' % cl.cc.target_requests_outstanding) | |
5da7763e | 190 | |
74934d63 IJ |
191 | if cto < cl.cc.http_timeout: |
192 | raise ValueError('cto must be >= %d' % cl.cc.http_timeout) | |
ba5630fd | 193 | |
d579a048 | 194 | try: |
e8fcf3b7 | 195 | d = request.args[b'd'][0] |
d579a048 | 196 | desca['d'] = d |
19f5f9b5 IJ |
197 | desca['dlen'] = len(d) |
198 | except KeyError: | |
199 | d = b'' | |
200 | desca['dlen'] = None | |
201 | ||
202 | log_http(desca, 'processing', idof=id(request), d=d) | |
5da7763e | 203 | |
6f387df3 IJ |
204 | d = mime_translate(d) |
205 | ||
a4e03162 IJ |
206 | cl.process_arriving_data(d) |
207 | cl.new_request(request) | |
5da7763e | 208 | |
19f5f9b5 | 209 | def log_http(desca, msg, **kwargs): |
8c3b6620 | 210 | try: |
19f5f9b5 | 211 | kwargs['d'] = desca['d'] |
8c3b6620 IJ |
212 | del desca['d'] |
213 | except KeyError: | |
19f5f9b5 IJ |
214 | pass |
215 | log_debug(DBG.HTTP, msg + repr(desca), **kwargs) | |
8c3b6620 | 216 | |
eb113b2c IJ |
217 | class NotStupidResource(twisted.web.resource.Resource): |
218 | # why this is not the default is a mystery! | |
219 | def getChild(self, name, request): | |
220 | if name == b'': return self | |
f963d7a3 | 221 | else: return twisted.web.resource.Resource.getChild(self, name, request) |
eb113b2c IJ |
222 | |
223 | class IphttpResource(NotStupidResource): | |
a4e03162 | 224 | def render_POST(self, request): |
297b3ebf IJ |
225 | log_debug(DBG.HTTP_FULL, |
226 | 'req recv: ' + repr(request) + ' ' + repr(request.args), | |
227 | idof=id(request)) | |
d579a048 IJ |
228 | desca = {'d': None} |
229 | try: process_request(request, desca) | |
0d10f35f | 230 | except Exception as e: |
68afd97b | 231 | emsg = traceback.format_exc() |
6f387df3 | 232 | log_http(desca, 'RETURNING EXCEPTION ' + emsg) |
0d10f35f IJ |
233 | request.setHeader('Content-Type','text/plain; charset="utf-8"') |
234 | request.setResponseCode(400) | |
a9a369c7 | 235 | return (emsg + ' # ' + repr(desca) + '\r\n').encode('utf-8') |
19f5f9b5 | 236 | log_debug(DBG.HTTP_CTRL, '...', idof=id(request)) |
d579a048 | 237 | return NOT_DONE_YET |
84f2d011 | 238 | |
b80a8f5c IJ |
239 | # instantiator should set |
240 | # self.hippotat_sources = (source_names[0], source_names[1]) | |
241 | def __init__(self): | |
242 | self.hippotat_sources = [None, None] | |
243 | super().__init__() | |
244 | ||
8e279651 | 245 | def render_GET(self, request): |
d579a048 | 246 | log_debug(DBG.HTTP, 'GET request') |
3c506501 IJ |
247 | s = '<html><body>hippotat\n' |
248 | (s0,s1) = self.hippotat_sources | |
249 | if s0: | |
250 | s += '<p><a href="%s">source</a>\n' % s0 | |
251 | if self.hippotat_sources[1]: | |
252 | s += ('(and that of dependency <a href="%s">packages</a>)\n' % s1) | |
253 | s += 'available' | |
254 | else: | |
255 | s += 'TESTING' | |
256 | s += '</body></html>' | |
257 | return s.encode('utf-8') | |
99e6411f | 258 | |
5da7763e IJ |
259 | def start_http(): |
260 | resource = IphttpResource() | |
b11c6e7a | 261 | site = twisted.web.server.Site(resource) |
a7d05900 | 262 | |
88487243 IJ |
263 | for sa in c.saddrs: |
264 | ep = sa.make_endpoint() | |
b11c6e7a | 265 | crash_on_defer(ep.listen(site)) |
d579a048 | 266 | log_debug(DBG.INIT, 'listening on %s' % sa) |
a7d05900 IJ |
267 | |
268 | td = tempfile.mkdtemp() | |
269 | ||
270 | def cleanup(): | |
271 | try: shutil.rmtree(td) | |
272 | except FileNotFoundError: pass | |
273 | ||
274 | cleanups.append(cleanup) | |
275 | ||
276 | ssp = SourceShipmentPreparer(td) | |
277 | ssp.logger = partial(log_debug, DBG.OWNSOURCE) | |
ff0fc3fa | 278 | if DBG.OWNSOURCE in debug_set: ssp.stream_debug = sys.stdout |
3c506501 IJ |
279 | ssp.download_packages = opts.ownsource >= 2 |
280 | if opts.ownsource >= 1: ssp.generate() | |
a7d05900 | 281 | |
b80a8f5c IJ |
282 | for ix in (0,1): |
283 | bn = ssp.output_names[ix] | |
284 | op = ssp.output_paths[ix] | |
3c506501 | 285 | if op is None: continue |
b80a8f5c IJ |
286 | resource.hippotat_sources[ix] = bn |
287 | subresource =twisted.web.static.File(op) | |
288 | resource.putChild(bn.encode('utf-8'), subresource) | |
a7d05900 | 289 | |
1e43fae0 | 290 | reactor.callLater(0.1, (lambda: log.info('hippotatd started', dflag=False))) |
5da7763e IJ |
291 | |
292 | #---------- config and setup ---------- | |
4a780703 | 293 | |
1cc6968f IJ |
294 | def process_cfg(_opts, putative_servers, putative_clients): |
295 | global opts | |
296 | opts = _opts | |
297 | ||
8d374606 | 298 | global c |
c7fb640e | 299 | c = ConfigResults() |
300fe4ed | 300 | try: c.server = cfg1get('SERVER','server') |
a97e7215 | 301 | except NoOptionError: c.server = 'SERVER' |
c7fb640e | 302 | |
62d13acc | 303 | cfg_process_general(c, c.server) |
8d374606 IJ |
304 | cfg_process_saddrs(c, c.server) |
305 | cfg_process_vnetwork(c, c.server) | |
306 | cfg_process_vaddr(c, c.server) | |
c7fb640e IJ |
307 | |
308 | for (ci,cs) in putative_clients.items(): | |
309 | cc = ConfigResults() | |
74934d63 | 310 | sections = cfg_process_client_common(cc,c.server,cs,ci) |
c7fb640e IJ |
311 | if not sections: continue |
312 | cfg_process_client_limited(cc,c.server,sections, 'max_batch_down') | |
313 | cfg_process_client_limited(cc,c.server,sections, 'max_queue_time') | |
ef041033 | 314 | cc.max_clock_skew = cfg_search(cfg.getint, 'max_clock_skew', sections) |
74934d63 | 315 | Client(ci, cc) |
e75e9c17 IJ |
316 | |
317 | try: | |
300fe4ed | 318 | c.vrelay = cfg1get(c.server, 'vrelay') |
e2d41dc1 | 319 | except NoOptionError: |
8d374606 IJ |
320 | for search in c.vnetwork.hosts(): |
321 | if search == c.vaddr: continue | |
74934d63 | 322 | c.vrelay = search |
e75e9c17 | 323 | break |
3fba9787 | 324 | |
300fe4ed | 325 | try: c.ifname = cfg1get(c.server, 'ifname_server', raw=True) |
d72f8360 IJ |
326 | except NoOptionError: pass |
327 | ||
8d374606 | 328 | cfg_process_ipif(c, |
71f9ddb6 | 329 | [c.server, 'COMMON'], |
c7fb640e IJ |
330 | (('local','vaddr'), |
331 | ('peer', 'vrelay'), | |
332 | ('rnets','vnetwork'))) | |
5bae5ba3 | 333 | |
bb450e0a | 334 | if opts.printconfig is not None: |
300fe4ed | 335 | try: val = cfg1get(c.server, opts.printconfig) |
bb450e0a IJ |
336 | except NoOptionError: pass |
337 | else: print(val) | |
338 | sys.exit(0) | |
339 | ||
4a780703 IJ |
340 | def catch_termination(): |
341 | def run_cleanups(): | |
342 | for cleanup in cleanups: | |
343 | cleanup() | |
344 | ||
345 | atexit.register(run_cleanups) | |
346 | ||
347 | def signal_handler(name, sig, *args): | |
348 | signal.signal(sig, signal.SIG_DFL) | |
349 | print('exiting due to %s' % name, file=sys.stderr) | |
350 | run_cleanups() | |
351 | os.kill(os.getpid(), sig) | |
352 | raise RuntimeError('did not die due to signal %s !' % name) | |
353 | ||
354 | for sig in (signal.SIGINT, signal.SIGTERM): | |
56afc487 IJ |
355 | try: signame = sig.name |
356 | except AttributeError: signame = "signal %d" % sig | |
357 | signal.signal(sig, partial(signal_handler, signame)) | |
4a780703 | 358 | |
ec2c9312 IJ |
359 | def daemonise(): |
360 | global syslogfacility | |
361 | if opts.daemon and opts.syslogfacility is None: | |
362 | opts.syslogfacility = 'daemon' | |
363 | ||
364 | if opts.syslogfacility is not None: | |
365 | facilnum = syslog.__dict__['LOG_' + opts.syslogfacility.upper()] | |
366 | syslog.openlog('hippotatd', | |
367 | facility=facilnum, | |
368 | logoption=syslog.LOG_PID) | |
369 | def emit(event): | |
0dc32c3f | 370 | if logevent_is_boringtwisted(event): return |
ec2c9312 IJ |
371 | m = twisted.logger.formatEvent(event) |
372 | #print(repr(event), m, file=org_stderr) | |
373 | level = event.get('log_level') | |
374 | if event.get('dflag',None) is not None: sl = syslog.LOG_DEBUG | |
375 | elif level == LogLevel.critical : sl = syslog.LOG_CRIT | |
376 | elif level == LogLevel.error : sl = syslog.LOG_ERR | |
377 | elif level == LogLevel.warn : sl = syslog.LOG_WARNING | |
378 | else : sl = syslog.LOG_INFO | |
379 | syslog.syslog(sl,m) | |
eb6dcb5a IJ |
380 | failure = event.get('log_failure') |
381 | if failure is not None: | |
382 | for l in failure.getTraceback().split('\n'): | |
383 | syslog.syslog(sl,l) | |
ec2c9312 IJ |
384 | glp = twisted.logger.globalLogPublisher |
385 | glp.addObserver(emit) | |
386 | log_debug(DBG.INIT, 'starting to log to syslog') | |
387 | ||
d84dbf4b IJ |
388 | #log.crit('daemonic hippotatd crashed', dflag=False) |
389 | if opts.daemon: | |
390 | daemonic_reactor = (twisted.internet.interfaces.IReactorDaemonize | |
391 | .providedBy(reactor)) | |
392 | if daemonic_reactor: reactor.beforeDaemonize() | |
27b796c5 IJ |
393 | if opts.pidfile is not None: |
394 | pidfile_h = open(opts.pidfile, 'w') | |
d84dbf4b IJ |
395 | rfd, wfd = os.pipe() |
396 | childpid = os.fork() | |
397 | if childpid: | |
398 | # we are the parent | |
399 | os.close(wfd) | |
400 | st = os.read(rfd, 1) | |
401 | try: | |
402 | st = st[0] | |
403 | except IndexError: | |
404 | st = 127 | |
405 | log.critical('daemonic hippotatd crashed', dflag=False) | |
406 | os._exit(st) | |
407 | os.close(rfd) | |
408 | os.setsid() | |
409 | grandchildpid = os.fork() | |
410 | if grandchildpid: | |
411 | # we are the intermediate child | |
27b796c5 | 412 | if opts.pidfile is not None: |
e6bec44d IJ |
413 | print(grandchildpid, file=pidfile_h) |
414 | pidfile_h.close() | |
d84dbf4b IJ |
415 | os._exit(0) |
416 | ||
e6bec44d IJ |
417 | if opts.pidfile is not None: |
418 | pidfile_h.close() | |
27b796c5 | 419 | |
d84dbf4b | 420 | logger = subprocess.Popen(['logger','-d', |
809bcf83 | 421 | '-t','hippotat[%d](stderr)' % os.getpid(), |
d84dbf4b IJ |
422 | '-p',opts.syslogfacility + '.err'], |
423 | stdin=subprocess.PIPE, | |
424 | stdout=subprocess.DEVNULL, | |
425 | stderr=subprocess.DEVNULL, | |
426 | restore_signals=True) | |
427 | ||
428 | nullfd = os.open('/dev/null', os.O_RDWR) | |
429 | os.dup2(nullfd, 0) | |
430 | os.dup2(nullfd, 1) | |
431 | os.dup2(logger.stdin.fileno(), 2) | |
432 | os.close(nullfd) | |
433 | if daemonic_reactor: reactor.afterDaemonize() | |
434 | log_debug(DBG.INIT, 'daemonised') | |
435 | os.write(wfd, b'\0') | |
436 | os.close(wfd) | |
437 | ||
438 | if opts.syslogfacility is not None: | |
ec2c9312 IJ |
439 | glp.removeObserver(hippotatlib.file_log_observer) |
440 | ||
3c506501 IJ |
441 | optparser.add_option('--ownsource', default=2, |
442 | action='store_const', dest='ownsource', const=2, | |
443 | help='source download fully enabled (default)') | |
444 | ||
445 | optparser.add_option('--ownsource-local', | |
446 | action='store_const', dest='ownsource', const=1, | |
447 | help='source download is local source code only') | |
448 | ||
449 | optparser.add_option('--no-ownsource', | |
450 | action='store_const', dest='ownsource', const=0, | |
451 | help='source download disabled (for testing only)') | |
452 | ||
d84dbf4b IJ |
453 | optparser.add_option('--daemon', |
454 | action='store_true', dest='daemon', default=False, | |
455 | help='daemonize (and log to syslog)') | |
456 | ||
2eecd19c IJ |
457 | optparser.add_option('--pidfile', |
458 | nargs=1, type='string', | |
459 | action='store', dest='pidfile', default=None, | |
460 | help='write pid to this file') | |
461 | ||
ec2c9312 IJ |
462 | optparser.add_option('--syslog-facility', |
463 | nargs=1, type='string',action='store', | |
464 | metavar='FACILITY', dest='syslogfacility', | |
465 | default=None, | |
466 | help='log to syslog, with specified facility') | |
467 | ||
bb450e0a IJ |
468 | optparser.add_option('--print-config', |
469 | nargs=1, type='string',action='store', | |
470 | metavar='OPTION', dest='printconfig', | |
471 | default=None, | |
472 | help='print one config option value and exit') | |
473 | ||
5510890e | 474 | common_startup(process_cfg) |
4a780703 | 475 | catch_termination() |
87a7c0c7 | 476 | start_http() |
ec2c9312 | 477 | daemonise() |
d84dbf4b | 478 | ipif = start_ipif(c.ipif_command, (lambda p,s,d: route(p,"[ipif]",s,d))) |
ae7c7784 | 479 | common_run() |