Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made interface to an optional parameter #153

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions broker/src/tunneldigger_broker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
RalfJung marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
3 changes: 2 additions & 1 deletion broker/src/tunneldigger_broker/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down