From a2b88dbf61fca69f9ce6c5ba19fc66c0fd535510 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 24 May 2016 12:46:42 -0700 Subject: [PATCH 1/2] server: add --signal-error CLI argument --- src/wormhole/server/cli_args.py | 2 ++ src/wormhole/server/cmd_server.py | 4 +++- src/wormhole/server/server.py | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wormhole/server/cli_args.py b/src/wormhole/server/cli_args.py index 4bc87e1..f6b32b5 100644 --- a/src/wormhole/server/cli_args.py +++ b/src/wormhole/server/cli_args.py @@ -24,6 +24,8 @@ sp_start.add_argument("--transit", default="tcp:3001", metavar="tcp:PORT", help="endpoint specification for the transit-relay port") sp_start.add_argument("--advertise-version", metavar="VERSION", help="version to recommend to clients") +sp_start.add_argument("--signal-error", metavar="ERROR", + help="force all clients to fail with a message") sp_start.add_argument("--blur-usage", default=None, type=int, metavar="SECONDS", help="round logged access times to improve privacy") diff --git a/src/wormhole/server/cmd_server.py b/src/wormhole/server/cmd_server.py index 938d451..02e6c66 100644 --- a/src/wormhole/server/cmd_server.py +++ b/src/wormhole/server/cmd_server.py @@ -13,7 +13,9 @@ class MyPlugin: from .server import RelayServer return RelayServer(self.args.rendezvous, self.args.transit, self.args.advertise_version, - "relay.sqlite", self.args.blur_usage) + "relay.sqlite", self.args.blur_usage, + signal_error=self.args.signal_error, + ) class MyTwistdConfig(twistd.ServerOptions): subCommands = [("XYZ", None, usage.Options, "node")] diff --git a/src/wormhole/server/server.py b/src/wormhole/server/server.py index 166a6ba..e182e1d 100644 --- a/src/wormhole/server/server.py +++ b/src/wormhole/server/server.py @@ -26,7 +26,8 @@ class PrivacyEnhancedSite(server.Site): class RelayServer(service.MultiService): def __init__(self, rendezvous_web_port, transit_port, - advertise_version, db_url=":memory:", blur_usage=None): + advertise_version, db_url=":memory:", blur_usage=None, + signal_error=None): service.MultiService.__init__(self) self._blur_usage = blur_usage @@ -42,6 +43,8 @@ class RelayServer(service.MultiService): } if advertise_version: welcome["current_version"] = advertise_version + if signal_error: + welcome["error"] = signal_error rendezvous = Rendezvous(db, welcome, blur_usage) rendezvous.setServiceParent(self) # for the pruning timer From fb2ffe1963f3d7482fb41c5199845b6647f364ab Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 24 May 2016 12:59:02 -0700 Subject: [PATCH 2/2] add --signal-error to restart too --- src/wormhole/server/cli_args.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wormhole/server/cli_args.py b/src/wormhole/server/cli_args.py index f6b32b5..d68d8db 100644 --- a/src/wormhole/server/cli_args.py +++ b/src/wormhole/server/cli_args.py @@ -49,6 +49,8 @@ sp_restart.add_argument("--transit", default="tcp:3001", metavar="tcp:PORT", help="endpoint specification for the transit-relay port") sp_restart.add_argument("--advertise-version", metavar="VERSION", help="version to recommend to clients") +sp_restart.add_argument("--signal-error", metavar="ERROR", + help="force all clients to fail with a message") sp_restart.add_argument("--blur-usage", default=None, type=int, metavar="SECONDS", help="round logged access times to improve privacy")