Skip to content

Commit

Permalink
Disallow listing nameplates by default
Browse files Browse the repository at this point in the history
  • Loading branch information
piegamesde committed Mar 31, 2023
1 parent 5b69792 commit 97746fb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/wormhole_mailbox_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions src/wormhole_mailbox_server/server_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 27 additions & 11 deletions src/wormhole_mailbox_server/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/wormhole_mailbox_server/test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_nameplate(self):
self.assertEqual(type(name), type(""))
nid = int(name)
self.assert_(0 < nid < 10, nid)
self.assertEqual(app.get_nameplate_ids(), set([name]))
self.assertEqual(app._get_nameplate_ids(), set([name]))
# allocate also does a claim
np_row, side_rows = self._nameplate(app, name)
self.assertEqual(len(side_rows), 1)
Expand Down
3 changes: 2 additions & 1 deletion src/wormhole_mailbox_server/test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 97746fb

Please sign in to comment.