From 2f4232a0e73cdc9d1f5658627589796bb1771a16 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 26 Jun 2017 13:49:24 +0100 Subject: [PATCH] server: only advertise the CLI version if requested with --advertise-version= refs #179 --- src/wormhole/server/server.py | 12 +++++------- src/wormhole/test/common.py | 3 +-- src/wormhole/test/test_server.py | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/wormhole/server/server.py b/src/wormhole/server/server.py index 4f94294..39cab57 100644 --- a/src/wormhole/server/server.py +++ b/src/wormhole/server/server.py @@ -7,7 +7,6 @@ from twisted.internet import reactor, endpoints from twisted.application import service, internet from twisted.web import server, static, resource from autobahn.twisted.resource import WebSocketResource -from .. import __version__ from .database import get_db from .rendezvous import Rendezvous from .rendezvous_websocket import WebSocketRendezvousFactory @@ -42,12 +41,6 @@ class RelayServer(service.MultiService): db = get_db(db_url) welcome = { - # 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.", @@ -55,7 +48,12 @@ class RelayServer(service.MultiService): # adding .error will cause all clients to fail, with this message #"error": "This server has been disabled, see URL for details.", } + if advertise_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. welcome["current_cli_version"] = advertise_version if signal_error: welcome["error"] = signal_error diff --git a/src/wormhole/test/common.py b/src/wormhole/test/common.py index e898ee9..69fc838 100644 --- a/src/wormhole/test/common.py +++ b/src/wormhole/test/common.py @@ -7,7 +7,6 @@ import mock from ..cli import cli from ..transit import allocate_tcp_port from ..server.server import RelayServer -from .. import __version__ class ServerBase: def setUp(self): @@ -22,7 +21,7 @@ class ServerBase: # endpoints.serverFromString s = RelayServer("tcp:%d:interface=127.0.0.1" % self.relayport, "tcp:%s:interface=127.0.0.1" % self.transitport, - advertise_version=__version__, + advertise_version="advertised.version", signal_error=error) s.setServiceParent(self.sp) self._relay_server = s diff --git a/src/wormhole/test/test_server.py b/src/wormhole/test/test_server.py index 351729c..5827ccd 100644 --- a/src/wormhole/test/test_server.py +++ b/src/wormhole/test/test_server.py @@ -6,7 +6,6 @@ from twisted.python import log from twisted.internet import reactor, defer from twisted.internet.defer import inlineCallbacks, returnValue from autobahn.twisted import websocket -from .. import __version__ from .common import ServerBase from ..server import server, rendezvous from ..server.rendezvous import Usage, SidedMessage @@ -625,7 +624,7 @@ class WebSocketAPI(_Util, ServerBase, unittest.TestCase): def check_welcome(self, data): self.failUnlessIn("welcome", data) self.failUnlessEqual(data["welcome"], - {"current_cli_version": __version__}) + {"current_cli_version": "advertised.version"}) @inlineCallbacks def test_welcome(self):