diff --git a/broker/l2tp_broker.cfg.example b/broker/l2tp_broker.cfg.example index 19b517d3..d630d9c9 100644 --- a/broker/l2tp_broker.cfg.example +++ b/broker/l2tp_broker.cfg.example @@ -3,7 +3,7 @@ address=127.0.0.1 ; Ports where the broker will listen on port=53,123,8942 -; Interface with that IP address +; Interface with that IP address (optional) interface=lo ; Maximum number of tunnels that will be allowed by the broker. ; On a cheap VPS, more than 256 tunnels usually do not make sense. diff --git a/broker/src/tunneldigger_broker/main.py b/broker/src/tunneldigger_broker/main.py index 57bba470..1f9d89ae 100644 --- a/broker/src/tunneldigger_broker/main.py +++ b/broker/src/tunneldigger_broker/main.py @@ -91,11 +91,18 @@ broker_host = config.get('broker', 'address') for port in config.get('broker', 'port').split(','): try: - broker_instance = broker.Broker( - (broker_host, int(port)), - config.get('broker', 'interface'), - tunnel_manager, - ) + if config.has_option('broker', 'interface'): + broker_instance = broker.Broker( + (broker_host, int(port)), + config.get('broker', 'interface'), + tunnel_manager, + ) + else: + broker_instance = broker.Broker( + (broker_host, int(port)), + None, + tunnel_manager, + ) logger.info("Listening on %s:%d." % broker_instance.address) except ValueError: logger.warning("Malformed port number '%s', skipping." % port) diff --git a/broker/src/tunneldigger_broker/network.py b/broker/src/tunneldigger_broker/network.py index da058444..bf9b5504 100644 --- a/broker/src/tunneldigger_broker/network.py +++ b/broker/src/tunneldigger_broker/network.py @@ -36,7 +36,8 @@ def __init__(self, address, interface): # Since we want all tunnel and tunnel control traffic to use the same port for # all clients we enable reuse of ports on the sockets we create. self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) - self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, interface.encode('utf-8')) + if interface is not None: + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, interface.encode('utf-8')) self.socket.bind(address) self.address = address diff --git a/docs/server.rst b/docs/server.rst index 64512a79..296e58a2 100644 --- a/docs/server.rst +++ b/docs/server.rst @@ -177,7 +177,7 @@ changed and some that can be left as default: * **port** should be configured with the external port (or ports separated by commas) that the clients will use to connect with the broker. -* **interface** should be configured with the name of the external interface that the clients will connect to. +* **interface** is a optional parameter and should be configured with the name of the external interface that the clients will connect to. * Hooks in the **hooks** section should be configured with paths to executable scripts that will be called when certain events occur in the broker. They are empty by default which means that tunnels will be established but they will not be configured.