+
+ def render_GET(self, request):
+ return b'<html><body>hippotat</body></html>'
+
+def start_http():
+ resource = IphttpResource()
+ site = twisted.web.server.Site(resource)
+ for addrspec in cfg.get('server','addrs').split():
+ try:
+ addr = ipaddress.IPv4Address(addrspec)
+ endpointfactory = twisted.internet.endpoints.TCP4ServerEndpoint
+ except AddressValueError:
+ addr = ipaddress.IPv6Address(addrspec)
+ endpointfactory = twisted.internet.endpoints.TCP6ServerEndpoint
+ ep = endpointfactory(reactor, cfg.getint('server','port'), addr)
+ crash_on_defer(ep.listen(site))
+
+#---------- config and setup ----------
+
+def process_cfg():
+ process_cfg_common_always()
+
+ c.network = ipnetwork(cfg.get('virtual','network'))
+ if c.network.num_addresses < 3 + 2:
+ raise ValueError('network needs at least 2^3 addresses')
+
+ try:
+ c.host = cfg.get('virtual','host')
+ except NoOptionError:
+ c.host = next(c.network.hosts())
+
+ try:
+ c.relay = cfg.get('virtual','relay')
+ except NoOptionError:
+ for search in c.network.hosts():
+ if search == c.host: continue
+ c.relay = search
+ break
+
+ for cs in cfg.sections():
+ if not (':' in cs or '.' in cs): continue
+ ci = ipaddr(cs)
+ if ci not in c.network:
+ raise ValueError('client %s not in network' % ci)
+ if ci in clients:
+ raise ValueError('multiple client cfg sections for %s' % ci)
+ clients[ci] = Client(ci, cs)
+
+ print(repr(c))
+
+ iic_vars = { }
+ for k in ('host','relay','mtu','network'):
+ iic_vars[k] = getattr(c,k)
+
+ c.ipif_command = cfg.get('server','ipif', vars=iic_vars)
+
+common_startup(defcfg)
+process_cfg()
+start_ipif(c.ipif_command, route)
+start_http()
+common_run()