Skip to content

Commit

Permalink
change default port= to listen on both IPv4+IPv6
Browse files Browse the repository at this point in the history
The default was "tcp:4001", which happens to expand into
"tcp:4001:interface=127.0.0.1", which limits the listening socket to IPv4
connections only.

Changing it to "tcp:4001:interface=\:\:1" means "listen on ::1", which is the
IPv6 name for the loopback interface, and gets us a socket that accepts both
IPv4 and IPv6 connections.

Note: this might cause incompatibilities with IPv4-only hosts, if they don't
accept the "::1" name. For these systems, run the server as `twist
transitrelay --port=tcp:4001" to revert to the old behavior.

closes #12
  • Loading branch information
warner committed Sep 11, 2019
1 parent e9f166c commit 273c4d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/wormhole_transit_relay/server_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Options(usage.Options):
longdesc = LONGDESC

optParameters = [
("port", "p", "tcp:4001", "endpoint to listen on"),
("port", "p", "tcp:4001:interface=\:\:1", "endpoint to listen on"),
("blur-usage", None, None, "blur timestamps and data sizes in logs"),
("log-fd", None, None, "write JSON usage logs to this file descriptor"),
("usage-db", None, None, "record usage data (SQLite)"),
Expand Down
6 changes: 4 additions & 2 deletions src/wormhole_transit_relay/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
from twisted.trial import unittest
from .. import server_tap

PORT = "tcp:4001:interface=\:\:1"

class Config(unittest.TestCase):
def test_defaults(self):
o = server_tap.Options()
o.parseOptions([])
self.assertEqual(o, {"blur-usage": None, "log-fd": None,
"usage-db": None, "port": "tcp:4001"})
"usage-db": None, "port": PORT})
def test_blur(self):
o = server_tap.Options()
o.parseOptions(["--blur-usage=60"])
self.assertEqual(o, {"blur-usage": 60, "log-fd": None,
"usage-db": None, "port": "tcp:4001"})
"usage-db": None, "port": PORT})

def test_string(self):
o = server_tap.Options()
Expand Down

0 comments on commit 273c4d7

Please sign in to comment.