2015-09-27 00:59:39 +00:00
|
|
|
from twisted.application import service
|
|
|
|
from ..twisted.util import allocate_ports
|
2015-10-04 19:40:12 +00:00
|
|
|
from ..servers.server import RelayServer
|
2015-09-27 00:59:39 +00:00
|
|
|
from .. import __version__
|
|
|
|
|
|
|
|
class ServerBase:
|
|
|
|
def setUp(self):
|
|
|
|
self.sp = service.MultiService()
|
|
|
|
self.sp.startService()
|
|
|
|
d = allocate_ports()
|
|
|
|
def _got_ports(ports):
|
|
|
|
relayport, transitport = ports
|
|
|
|
s = RelayServer("tcp:%d:interface=127.0.0.1" % relayport,
|
|
|
|
"tcp:%s:interface=127.0.0.1" % transitport,
|
|
|
|
__version__)
|
|
|
|
s.setServiceParent(self.sp)
|
2015-10-07 00:20:12 +00:00
|
|
|
self._relay_server = s.relay
|
2015-12-04 03:45:34 +00:00
|
|
|
self._transit_server = s.transit
|
2015-10-06 23:52:33 +00:00
|
|
|
self.relayurl = u"http://127.0.0.1:%d/wormhole-relay/" % relayport
|
2015-12-03 22:24:52 +00:00
|
|
|
self.transit = u"tcp:127.0.0.1:%d" % transitport
|
2015-09-27 00:59:39 +00:00
|
|
|
d.addCallback(_got_ports)
|
|
|
|
return d
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
return self.sp.stopService()
|