Commit 752cfeea authored by Julien Muchembled's avatar Julien Muchembled

re6stnet: new --main-interface option

parent 8858e886
...@@ -149,7 +149,7 @@ if 1: ...@@ -149,7 +149,7 @@ if 1:
registry.screen('../re6stnet @registry/re6stnet.conf --ip 10.0.0.2 -v%u' % VERBOSE, registry.screen('../re6stnet @registry/re6stnet.conf --ip 10.0.0.2 -v%u' % VERBOSE,
'../re6st-registry @registry/re6st-registry.conf -v%u' '../re6st-registry @registry/re6st-registry.conf -v%u'
' --mailhost %s' % (VERBOSE, os.path.abspath('mbox'))) ' --mailhost %s' % (VERBOSE, os.path.abspath('mbox')))
machine1.screen('../re6stnet @m1/re6stnet.conf -v%u' % VERBOSE) machine1.screen('../re6stnet @m1/re6stnet.conf -v%u -I%s' % (VERBOSE, m1_if_0.name))
machine2.screen('../re6stnet @m2/re6stnet.conf -v%u' % VERBOSE) machine2.screen('../re6stnet @m2/re6stnet.conf -v%u' % VERBOSE)
machine3.screen('../re6stnet @m3/re6stnet.conf -v%u -i%s' % (VERBOSE, m3_if_0.name)) machine3.screen('../re6stnet @m3/re6stnet.conf -v%u -i%s' % (VERBOSE, m3_if_0.name))
machine4.screen('../re6stnet @m4/re6stnet.conf -v%u -i%s' % (VERBOSE, m4_if_0.name)) machine4.screen('../re6stnet @m4/re6stnet.conf -v%u -i%s' % (VERBOSE, m4_if_0.name))
......
...@@ -32,6 +32,9 @@ def getConfig(): ...@@ -32,6 +32,9 @@ def getConfig():
_('-i', '--interface', action='append', dest='iface_list', default=[], _('-i', '--interface', action='append', dest='iface_list', default=[],
help="Extra interface for LAN discovery. Highly recommanded if there" help="Extra interface for LAN discovery. Highly recommanded if there"
" are other re6st node on the same network segment.") " are other re6st node on the same network segment.")
_('-I', '--main-interface', metavar='IFACE',
help="Set re6stnet IP on given interface. Any interface not used for"
" tunnelling can be chosen. (default: first OpenVPN interface)")
_ = parser.add_argument_group('routing').add_argument _ = parser.add_argument_group('routing').add_argument
_('-B', dest='babel_args', metavar='ARG', action='append', default=[], _('-B', dest='babel_args', metavar='ARG', action='append', default=[],
...@@ -183,25 +186,29 @@ def main(): ...@@ -183,25 +186,29 @@ def main():
if config.client: if config.client:
cleanup.append(plib.client('re6stnet', config.client, cleanup.append(plib.client('re6stnet', config.client,
config.encrypt, config.encrypt,
'--up', plib.ovpn_server + ' ' + my_ip, '--up', '%s %s' % (plib.ovpn_server, None
if config.main_interface else my_ip),
'--ping-restart', str(4 * config.hello), '--ping-restart', str(4 * config.hello),
*config.openvpn_args).kill) *config.openvpn_args).kill)
elif server_tunnels: elif server_tunnels:
required('dh') required('dh')
for iface, (port, proto) in server_tunnels.iteritems(): for iface, (port, proto) in server_tunnels.iteritems():
cleanup.append(plib.server(iface, cleanup.append(plib.server(iface, None
my_ip if proto == pp[0][1] else None, if config.main_interface or proto != pp[0][1]
config.max_clients, config.dh, write_pipe, port, else my_ip, config.max_clients, config.dh, write_pipe,
proto, config.encrypt, *config.openvpn_args).kill) port, proto, config.encrypt, *config.openvpn_args).kill)
elif config.iface_list: elif config.iface_list and not config.main_interface:
config.main_interface = config.iface_list[0]
else:
sys.exit("--client, --interface or --main-interface required"
" when --max-clients is 0")
if config.main_interface:
ip_args = ['ip', 'addr', 'add', my_ip, ip_args = ['ip', 'addr', 'add', my_ip,
'dev', config.iface_list[0]] 'dev', config.main_interface]
call(ip_args) call(ip_args)
ip_args[2] = 'del' ip_args[2] = 'del'
cleanup.append(lambda: call(ip_args)) cleanup.append(lambda: call(ip_args))
else:
sys.exit("--client or --interface required"
" when --max-clients is 0")
# main loop # main loop
if tunnel_manager is None: if tunnel_manager is None:
......
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