server: only advertise the CLI version if requested
with --advertise-version= refs #179
This commit is contained in:
parent
572f6e3c16
commit
2f4232a0e7
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user