diff --git a/src/wormhole/server/rendezvous_websocket.py b/src/wormhole/server/rendezvous_websocket.py index c824d43..97b382a 100644 --- a/src/wormhole/server/rendezvous_websocket.py +++ b/src/wormhole/server/rendezvous_websocket.py @@ -49,7 +49,7 @@ from ..util import dict_to_bytes, bytes_to_dict # connection -> welcome # <- {type: "welcome", welcome: {}} # .welcome keys are all optional: -# current_version: out-of-date clients display a warning +# current_cli_version: out-of-date clients display a warning # motd: all clients display message, then continue normally # error: all clients display mesage, then terminate with error # -> {type: "bind", appid:, side:} diff --git a/src/wormhole/server/server.py b/src/wormhole/server/server.py index faa598f..bca7565 100644 --- a/src/wormhole/server/server.py +++ b/src/wormhole/server/server.py @@ -32,16 +32,21 @@ class RelayServer(service.MultiService): db = get_db(db_url) welcome = { - "current_version": __version__, + # The primary (python CLI) implementation will emit a message if + # its version does not match this key. If/when we have + # distributions which include older version, but we still expect + # them to be compatible, stop sending this key. + "current_cli_version": __version__, + # adding .motd will cause all clients to display the message, # then keep running normally #"motd": "Welcome to the public relay.\nPlease enjoy this service.", - # + # adding .error will cause all clients to fail, with this message #"error": "This server has been disabled, see URL for details.", } if advertise_version: - welcome["current_version"] = advertise_version + welcome["current_cli_version"] = advertise_version if signal_error: welcome["error"] = signal_error diff --git a/src/wormhole/test/test_server.py b/src/wormhole/test/test_server.py index b8e3009..40e5bd8 100644 --- a/src/wormhole/test/test_server.py +++ b/src/wormhole/test/test_server.py @@ -615,7 +615,8 @@ class WebSocketAPI(ServerBase, unittest.TestCase): def check_welcome(self, data): self.failUnlessIn("welcome", data) - self.failUnlessEqual(data["welcome"], {"current_version": __version__}) + self.failUnlessEqual(data["welcome"], + {"current_cli_version": __version__}) @inlineCallbacks def test_welcome(self): diff --git a/src/wormhole/test/test_wormhole.py b/src/wormhole/test/test_wormhole.py index 820f058..9bfc97d 100644 --- a/src/wormhole/test/test_wormhole.py +++ b/src/wormhole/test/test_wormhole.py @@ -36,11 +36,11 @@ def response(w, **kwargs): class Welcome(unittest.TestCase): def test_tolerate_no_current_version(self): - w = wormhole._WelcomeHandler(u"relay_url", u"current_version", None) + w = wormhole._WelcomeHandler(u"relay_url", u"current_cli_version", None) w.handle_welcome({}) def test_print_motd(self): - w = wormhole._WelcomeHandler(u"relay_url", u"current_version", None) + w = wormhole._WelcomeHandler(u"relay_url", u"current_cli_version", None) with mock.patch("sys.stderr") as stderr: w.handle_welcome({u"motd": u"message of\nthe day"}) self.assertEqual(stderr.method_calls, @@ -55,11 +55,11 @@ class Welcome(unittest.TestCase): def test_current_version(self): w = wormhole._WelcomeHandler(u"relay_url", u"2.0", None) with mock.patch("sys.stderr") as stderr: - w.handle_welcome({u"current_version": u"2.0"}) + w.handle_welcome({u"current_cli_version": u"2.0"}) self.assertEqual(stderr.method_calls, []) with mock.patch("sys.stderr") as stderr: - w.handle_welcome({u"current_version": u"3.0"}) + w.handle_welcome({u"current_cli_version": u"3.0"}) exp1 = (u"Warning: errors may occur unless both sides are" " running the same version") exp2 = (u"Server claims 3.0 is current, but ours is 2.0") @@ -72,13 +72,13 @@ class Welcome(unittest.TestCase): # warning is only displayed once with mock.patch("sys.stderr") as stderr: - w.handle_welcome({u"current_version": u"3.0"}) + w.handle_welcome({u"current_cli_version": u"3.0"}) self.assertEqual(stderr.method_calls, []) def test_non_release_version(self): w = wormhole._WelcomeHandler(u"relay_url", u"2.0-dirty", None) with mock.patch("sys.stderr") as stderr: - w.handle_welcome({u"current_version": u"3.0"}) + w.handle_welcome({u"current_cli_version": u"3.0"}) self.assertEqual(stderr.method_calls, []) def test_signal_error(self): diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index b96d6c7..d6ff875 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -193,13 +193,13 @@ class _WelcomeHandler: # Only warn if we're running a release version (e.g. 0.0.6, not # 0.0.6-DISTANCE-gHASH). Only warn once. - if ("current_version" in welcome + if ("current_cli_version" in welcome and "-" not in self._current_version and not self._version_warning_displayed - and welcome["current_version"] != self._current_version): + and welcome["current_cli_version"] != self._current_version): print("Warning: errors may occur unless both sides are running the same version", file=sys.stderr) print("Server claims %s is current, but ours is %s" - % (welcome["current_version"], self._current_version), + % (welcome["current_cli_version"], self._current_version), file=sys.stderr) self._version_warning_displayed = True