Commit b2040ea0 authored by Julien Muchembled's avatar Julien Muchembled

Make --client & --client-count=0 modes process UDP/326 messages

These modes are partly unified with the normal one by splitting TunnelManager.
parent 9717eb0e
This diff is collapsed.
...@@ -256,20 +256,20 @@ def main(): ...@@ -256,20 +256,20 @@ def main():
# Init db and tunnels # Init db and tunnels
tunnel_interfaces = server_tunnels.keys() tunnel_interfaces = server_tunnels.keys()
timeout = 4 * config.hello timeout = 4 * config.hello
cleanup = []
if config.client_count and not config.client:
peer_db = db.PeerDB(db_path, config.registry, cert) peer_db = db.PeerDB(db_path, config.registry, cert)
cleanup.append(lambda: peer_db.cacheMinimize(config.client_count)) cleanup = [lambda: peer_db.cacheMinimize(config.client_count)]
if config.client_count and not config.client:
tunnel_manager = tunnel.TunnelManager(config.control_socket, tunnel_manager = tunnel.TunnelManager(config.control_socket,
peer_db, cert, config.openvpn_args, timeout, peer_db, cert, config.openvpn_args, timeout,
config.tunnel_refresh, config.client_count, config.iface_list, config.tunnel_refresh, config.client_count, config.iface_list,
address, ip_changed, config.encrypt, remote_gateway, address, ip_changed, config.encrypt, remote_gateway,
config.disable_proto, config.neighbour) config.disable_proto, config.neighbour)
cleanup.append(tunnel_manager.sock.close)
tunnel_interfaces += tunnel_manager.new_iface_list tunnel_interfaces += tunnel_manager.new_iface_list
write_pipe = tunnel_manager.write_pipe write_pipe = tunnel_manager.write_pipe
else: else:
tunnel_manager = write_pipe = None write_pipe = None
tunnel_manager = tunnel.BaseTunnelManager(peer_db, cert)
cleanup.append(tunnel_manager.sock.close)
try: try:
exit.acquire() exit.acquire()
...@@ -372,17 +372,18 @@ def main(): ...@@ -372,17 +372,18 @@ def main():
exit.acquire() exit.acquire()
for cmd in config.daemon or (): for cmd in config.daemon or ():
cleanup.insert(-1, utils.Popen(cmd, shell=True).stop) cleanup.insert(-1, utils.Popen(cmd, shell=True).stop)
try:
# main loop
select_list = [forwarder.select] if forwarder else []
if tunnel_manager:
select_list.append(tunnel_manager.select)
cleanup[-1:-1] = (tunnel_manager.delInterfaces, cleanup[-1:-1] = (tunnel_manager.delInterfaces,
tunnel_manager.killAll) tunnel_manager.killAll)
except AttributeError:
pass
# main loop
exit.release() exit.release()
def renew(): def renew():
raise ReexecException("Restart to renew certificate") raise ReexecException("Restart to renew certificate")
select_list.append(utils.select) select_list = [forwarder.select] if forwarder else []
select_list += tunnel_manager.select, utils.select
while True: while True:
args = {}, {}, [(next_renew, renew)] args = {}, {}, [(next_renew, renew)]
for s in select_list: for s in select_list:
......
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