INCOMPATIBILITY: send "current_cli_version", not "current_version"

The reasoning is that this string is only ever likely to refer to the
version of the primary/initial client (the CLI application, written in
Python, that you get with "pip install magic-wormhole"). When there are
other implementations, with unrelated versions, they should obviously
not pay attention to a warning about the other implementation being out
of date.
This commit is contained in:
Brian Warner 2016-05-28 19:11:27 -07:00
parent 0b53094927
commit 52e5cbd690
5 changed files with 20 additions and 14 deletions

View File

@ -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:}

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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