diff --git a/src/wormhole/server/endpoint_service.py b/src/wormhole/server/endpoint_service.py deleted file mode 100644 index 40c9234..0000000 --- a/src/wormhole/server/endpoint_service.py +++ /dev/null @@ -1,27 +0,0 @@ -from __future__ import unicode_literals -from twisted.python import log -from twisted.internet import defer -from twisted.application import service - -# this should probably live in Twisted - -class ServerEndpointService(service.Service): - def __init__(self, endpoint, factory): - self.endpoint = endpoint - self.factory = factory - self._started = defer.Deferred() - self._listeningport = None - - def startService(self): - d = self.endpoint.listen(self.factory) - def _set_port(listeningport): - self._listeningport = listeningport - self._started.callback(listeningport) - d.addCallback(_set_port) - d.addErrback(log.err) - - def stopService(self): - def _stop(port): - return port.stopListening() - self._started.addCallback(_stop) - return self._started diff --git a/src/wormhole/server/server.py b/src/wormhole/server/server.py index 6b2419f..3ac8215 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 .endpoint_service import ServerEndpointService from .. import __version__ from .database import get_db from .rendezvous import Rendezvous @@ -71,14 +70,14 @@ class RelayServer(service.MultiService): site.logRequests = False r = endpoints.serverFromString(reactor, rendezvous_web_port) - rendezvous_web_service = ServerEndpointService(r, site) + rendezvous_web_service = internet.StreamServerEndpointService(r, site) rendezvous_web_service.setServiceParent(self) if transit_port: transit = Transit(db, blur_usage) transit.setServiceParent(self) # for the timer t = endpoints.serverFromString(reactor, transit_port) - transit_service = ServerEndpointService(t, transit) + transit_service = internet.StreamServerEndpointService(t, transit) transit_service.setServiceParent(self) self._stats_file = stats_file