chiark
/
gitweb
/
~mdw
/
hippotat
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
094ee3a
)
wip
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 19 Mar 2017 19:13:26 +0000
(19:13 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 19 Mar 2017 19:13:26 +0000
(19:13 +0000)
server
patch
|
blob
|
blame
|
history
diff --git
a/server
b/server
index 6c229a92bcd930680a209438a6c31678304fb6af..9d8338616e76c6343a6947e890f870d222eb2e55 100755
(executable)
--- a/
server
+++ b/
server
@@
-5,7
+5,9
@@
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET
from twisted.internet import reactor
from twisted.web.server import NOT_DONE_YET
from twisted.internet import reactor
-import configparser
+from optparse import OptionParser
+from configparser import ConfigParser
+from configparser import NoOptionError
import ipaddress
import collections
import ipaddress
import collections
@@
-28,12
+30,21
@@
def ipnetwork(input):
r = ipaddress.IPv6Network(input)
return r
r = ipaddress.IPv6Network(input)
return r
-defcfg =
u
'''
+defcfg = '''
[DEFAULT]
max_batch_down = 65536
max_queue_time = 10
max_request_time = 54
[DEFAULT]
max_batch_down = 65536
max_queue_time = 10
max_request_time = 54
+[virtual]
+mtu = 1500
+# network
+# [host]
+# [relay]
+
+[server]
+ipif_program = userv root ipif %(host),%(relay),%(mtu),slip %(network)
+
[limits]
max_batch_down = 262144
max_queue_time = 121
[limits]
max_batch_down = 262144
max_queue_time = 121
@@
-136,13
+147,25
@@
class Client():
def process_cfg():
global network
def process_cfg():
global network
- global ourself
+ global host
+ global relay
network = ipnetwork(cfg.get('virtual','network'))
network = ipnetwork(cfg.get('virtual','network'))
+ if network.num_addresses < 3 + 2:
+ raise ValueError('network needs at least 2^3 addresses')
+
try:
try:
- ourself = cfg.get('virtual','server')
- except ConfigParser.NoOptionError:
- ourself = network.hosts().next()
+ host = cfg.get('virtual','host')
+ except NoOptionError:
+ host = network.hosts().next()
+
+ try:
+ relay = cfg.get('virtual','relay')
+ except OptionError:
+ for search in network.hosts():
+ if search = host: continue
+ relay = search
+ break
for cs in cfg.sections():
if not (':' in cs or '.' in cs): continue
for cs in cfg.sections():
if not (':' in cs or '.' in cs): continue
@@
-175,3
+198,14
@@
class FormPage(Resource):
c.process_arriving_data(d)
c.new_request(request)
c.process_arriving_data(d)
c.new_request(request)
+
+def startup():
+ op = OptionParser()
+ op.add_option('-c', '--config', dest='configfile',
+ default='/etc/hippottd/server.conf')
+ global opts
+ (opts, args) = op.parse_args()
+ if len(args): op.error('no non-option arguments please')
+
+ cfg = ConfigParser()
+