Commit f73c51ec authored by Julien Muchembled's avatar Julien Muchembled

Move runtime files to a subdirectory and simplify command-line options

We consider using sockets to communicate with OpenVPN, via --management option.
parent 1257f36c
......@@ -172,7 +172,7 @@ if 1:
crypto.dump_certificate(crypto.FILETYPE_ASN1, ca)).hexdigest()
db_path = 'registry/registry.db'
registry.screen('./py re6st-registry @registry/re6st-registry.conf'
' --db %s --mailhost %s -v%u --control-socket registry/babeld.socket'
' --db %s --mailhost %s -v%u'
% (db_path, os.path.abspath('mbox'), VERBOSE))
registry_url = 'http://%s/' % REGISTRY
registry.Popen(('python', '-c', """if 1:
......@@ -207,9 +207,8 @@ if 1:
p.communicate(str(token[0]))
os.remove(dh_path)
os.remove(folder + '/ca.crt')
node.screen('./py re6stnet @%s/re6stnet.conf -v%u --registry %s'
' --control-socket %s/babeld.socket'
' %s' % (folder, VERBOSE, registry, folder, args))
node.screen('./py re6stnet @%s/re6stnet.conf -v%u --registry %s %s'
% (folder, VERBOSE, registry, args))
re6stnet(registry, 'registry', '--ip ' + REGISTRY, registry='http://localhost/')
re6stnet(machine1, 'm1', '-I%s' % m1_if_0.name)
re6stnet(machine2, 'm2', '--remote-gateway 10.1.1.1', prefix_len=80)
......
log m1/
run m1/run
state m1/
babel-pidfile m1/babeld.pid
pp 1194 tcp
dh dh2048.pem
ca ca.crt
......
log m2/
run m2/run
state m2/
babel-pidfile m2/babeld.pid
pp 1194 tcp
dh dh2048.pem
ca ca.crt
......
log m3/
run m3/run
state m3/
babel-pidfile m3/babeld.pid
pp 1194 tcp
dh dh2048.pem
ca ca.crt
......
log m4/
run m4/run
state m4/
babel-pidfile m4/babeld.pid
pp 1194 tcp
dh dh2048.pem
ca ca.crt
......
log m5/
run m5/run
state m5/
babel-pidfile m5/babeld.pid
ca ca.crt
cert m5/cert.crt
key m5/cert.key
......
log m6/
run m6/run
state m6/
babel-pidfile m6/babeld.pid
pp 1194 tcp
dh dh2048.pem
ca ca.crt
......
log m7/
run m7/run
state m7/
babel-pidfile m7/babeld.pid
pp 1194 tcp
dh dh2048.pem
ca ca.crt
......
log m8/
run m8/run
state m8/
babel-pidfile m8/babeld.pid
ca ca.crt
cert m8/cert.crt
key m8/cert.key
......
ca ca.crt
key registry/ca.key
logfile registry/registry.log
run registry/run
hello 4
client-count 2
tunnel-refresh 100
log registry/
run registry/run
state registry/
babel-pidfile registry/babeld.pid
dh dh2048.pem
ca ca.crt
cert registry/cert.crt
......
......@@ -81,11 +81,11 @@ def main():
_('--anonymous-prefix-length', type=int,
help="Length of allocated anonymous prefixes."
" If 0 or unset, registration by email is required")
_('--control-socket', metavar='CTL_SOCK', default=ctl.SOCK_PATH,
help="Socket path to use for communication between re6stnet and babeld"
" (option -R of Babel).")
_('-l', '--logfile', default='/var/log/re6stnet/registry.log',
help="Path to logging file.")
_('-r', '--run', default='/var/run/re6stnet',
help="Path to re6stnet runtime directory:\n"
"- babeld.sock (option -R of babeld)\n")
_('-v', '--verbose', default=1, type=int,
help="Log level. 0 disables logging."
" Use SIGUSR1 to reopen log.")
......
......@@ -2,8 +2,6 @@ import logging, socket, struct
from collections import namedtuple
from . import utils
SOCK_PATH = '/var/run/re6st-babeld.sock'
uint16 = struct.Struct("!H")
header = struct.Struct("!HI")
......
......@@ -80,7 +80,7 @@ class RegistryServer(object):
self.email = self.cert.ca.get_subject().emailAddress
self.peers_lock = threading.Lock()
self.ctl = ctl.Babel(config.control_socket,
self.ctl = ctl.Babel(os.path.join(config.run, 'babeld.sock'),
weakref.proxy(self), self.network)
self.onTimeout()
......
......@@ -190,9 +190,9 @@ def select(R, W, T):
if next_refresh <= t:
refresh()
def makedirs(path):
def makedirs(*args):
try:
os.makedirs(path)
os.makedirs(*args)
except OSError, e:
if e.errno != errno.EEXIST:
raise
......
#!/usr/bin/python
import atexit, errno, logging, os, signal, socket
import subprocess, sys, time, threading
import atexit, errno, logging, os, shutil, signal
import socket, subprocess, sys, time, threading
from collections import deque
from re6st import ctl, plib, tunnel, utils, version, x509
from re6st import plib, tunnel, utils, version, x509
from re6st.cache import Cache
from re6st.utils import exit, ReexecException
......@@ -25,6 +25,10 @@ def getConfig():
"- re6stnet.log: log file of re6stnet itself\n"
"- babeld.log: log file of router\n"
"- <iface>.log: 1 file per spawned OpenVPN\n")
_('-r', '--run', default='/var/run/re6stnet',
help="Path to re6stnet runtime directory:\n"
"- babeld.pid (option -I of babeld)\n"
"- babeld.sock (option -R of babeld)\n")
_('-s', '--state', default='/var/lib/re6stnet',
help="Path to re6stnet state directory:\n"
"- cache.db: cache of network parameters and peer addresses\n"
......@@ -53,12 +57,6 @@ def getConfig():
_ = parser.add_argument_group('routing').add_argument
_('-B', dest='babel_args', metavar='ARG', action='append', default=[],
help="Extra arguments to forward to Babel.")
_('--babel-pidfile', metavar='PID', default='/var/run/re6st-babeld.pid',
help="Specify a file to write our process id to"
" (option -I of Babel).")
_('--control-socket', metavar='CTL_SOCK', default=ctl.SOCK_PATH,
help="Socket path to use for communication between re6stnet and babeld"
" (option -R of Babel).")
_('--table', type=int, default=42,
help="Use given table id. Set 0 to use the main table, if you want to"
" access internet via this network (in this case, make sure you"
......@@ -245,9 +243,12 @@ def main():
# Init db and tunnels
tunnel_interfaces = server_tunnels.keys()
timeout = 4 * cache.hello
cleanup = [lambda: cache.cacheMinimize(config.client_count)]
cleanup = [lambda: cache.cacheMinimize(config.client_count),
lambda: shutil.rmtree(config.run, True)]
utils.makedirs(config.run, 0700)
control_socket = os.path.join(config.run, 'babeld.sock')
if config.client_count and not config.client:
tunnel_manager = tunnel.TunnelManager(config.control_socket,
tunnel_manager = tunnel.TunnelManager(control_socket,
cache, cert, next_renew, config.openvpn_args, timeout,
config.client_count, config.iface_list, address, ip_changed,
remote_gateway, config.disable_proto, config.neighbour)
......@@ -348,8 +349,8 @@ def main():
cleanup.append(plib.router(subnet, cache.hello, config.table,
os.path.join(config.log, 'babeld.log'),
os.path.join(config.state, 'babeld.state'),
config.babel_pidfile, tunnel_interfaces,
config.control_socket, cache.babel_default,
os.path.join(config.run, 'babeld.pid'),
tunnel_interfaces, control_socket, cache.babel_default,
*config.babel_args).stop)
if config.up:
exit.release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment