diff --git a/src/wormhole_mailbox_server/server.py b/src/wormhole_mailbox_server/server.py index e975d0e..3c96a82 100644 --- a/src/wormhole_mailbox_server/server.py +++ b/src/wormhole_mailbox_server/server.py @@ -679,7 +679,7 @@ def stopService(self): app._shutdown() return service.MultiService.stopService(self) -def make_server(db, allow_list=True, +def make_server(db, allow_list=False, advertise_version=None, signal_error=None, blur_usage=None, diff --git a/src/wormhole_mailbox_server/server_tap.py b/src/wormhole_mailbox_server/server_tap.py index 9330b6b..48bf751 100644 --- a/src/wormhole_mailbox_server/server_tap.py +++ b/src/wormhole_mailbox_server/server_tap.py @@ -29,16 +29,22 @@ class Options(usage.Options): ("motd", None, None, "Send a Message of the Day in the welcome"), ] optFlags = [ - ("disallow-list", None, "refuse to send list of allocated nameplates"), + ("disallow-list", None, "default. refuse to send list of allocated nameplates"), + ("allow-list", None, "allow to send list of allocated nameplates"), ] def __init__(self): super(Options, self).__init__() + # Default values self["websocket-protocol-options"] = [] - self["allow-list"] = True + self["allow-list"] = False def opt_disallow_list(self): - self["allow-list"] = False + # no-op because default + pass + + def opt_allow_list(self): + self["allow-list"] = True def opt_log_fd(self, arg): self["log-fd"] = int(arg) diff --git a/src/wormhole_mailbox_server/test/test_config.py b/src/wormhole_mailbox_server/test/test_config.py index dc4e5d5..ec7a9cd 100644 --- a/src/wormhole_mailbox_server/test/test_config.py +++ b/src/wormhole_mailbox_server/test/test_config.py @@ -12,7 +12,7 @@ def test_defaults(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -28,7 +28,7 @@ def test_advertise_version(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": "1.0", "signal-error": None, "usage-db": None, @@ -44,7 +44,7 @@ def test_blur(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -60,7 +60,7 @@ def test_channel_db(self): self.assertEqual(o, {"port": PORT, "channel-db": "other.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -86,13 +86,29 @@ def test_disallow_list(self): "websocket-protocol-options": [], }) + def test_allow_list(self): + o = server_tap.Options() + o.parseOptions(["--allow-list"]) + self.assertEqual(o, {"port": PORT, + "channel-db": "relay.sqlite", + "disallow-list": 0, + "allow-list": True, + "advertise-version": None, + "signal-error": None, + "usage-db": None, + "blur-usage": None, + "motd": None, + "log-fd": None, + "websocket-protocol-options": [], + }) + def test_log_fd(self): o = server_tap.Options() o.parseOptions(["--log-fd=5"]) self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -108,7 +124,7 @@ def test_port(self): self.assertEqual(o, {"port": "tcp:5555", "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -123,7 +139,7 @@ def test_port(self): self.assertEqual(o, {"port": "tcp:5555", "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -139,7 +155,7 @@ def test_signal_error(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": "ohnoes", "usage-db": None, @@ -155,7 +171,7 @@ def test_usage_db(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": "usage.sqlite", @@ -171,7 +187,7 @@ def test_websocket_protocol_option_1(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, @@ -189,7 +205,7 @@ def test_websocket_protocol_option_2(self): self.assertEqual(o, {"port": PORT, "channel-db": "relay.sqlite", "disallow-list": 0, - "allow-list": True, + "allow-list": False, "advertise-version": None, "signal-error": None, "usage-db": None, diff --git a/src/wormhole_mailbox_server/test/test_web.py b/src/wormhole_mailbox_server/test/test_web.py index f2c45c9..fdfc30d 100644 --- a/src/wormhole_mailbox_server/test/test_web.py +++ b/src/wormhole_mailbox_server/test/test_web.py @@ -94,7 +94,8 @@ def setUp(self): self._usage_db = usage_db = create_or_upgrade_usage_db(":memory:") yield self._setup_relay(do_listen=True, advertise_version="advertised.version", - usage_db=usage_db) + usage_db=usage_db, + allow_list=True) def tearDown(self): for c in self._clients: