From b095b6919a4d829f282bb1e5674a3743c0a1889c Mon Sep 17 00:00:00 2001 From: meejah Date: Wed, 7 Apr 2021 16:28:19 -0600 Subject: [PATCH] cleanup --- src/wormhole_transit_relay/transit_server.py | 4 +++- ws_client.py | 13 ++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/wormhole_transit_relay/transit_server.py b/src/wormhole_transit_relay/transit_server.py index a20c5de..be543d1 100644 --- a/src/wormhole_transit_relay/transit_server.py +++ b/src/wormhole_transit_relay/transit_server.py @@ -58,6 +58,7 @@ class TransitConnection(LineReceiver): """ if self._buddy is not None: log.msg("buddy_disconnected {}".format(self._buddy.get_token())) + # XXX if our buddy is a WebSocket, this isn't the right way? self._buddy._client.transport.loseConnection() self._buddy = None @@ -237,7 +238,8 @@ class WebSocketTransitConnection(WebSocketServerProtocol): """ if self._buddy is not None: log.msg("buddy_disconnected {}".format(self._buddy.get_token())) - self._buddy._client.transport.loseConnection() + # XXX if our buddy is tcp this is wrong + self._buddy._client.disconnect() self._buddy = None def connectionMade(self): diff --git a/ws_client.py b/ws_client.py index e5fbbd3..f6219da 100644 --- a/ws_client.py +++ b/ws_client.py @@ -36,11 +36,6 @@ class RelayEchoClient(WebSocketClientProtocol): True, ) - # def onConnecting(self, details): - # return types.ConnectingRequest( - # protocols=["binary"], - # ) - def onMessage(self, data, isBinary): print(">onMessage: {} bytes".format(len(data))) print(data, isBinary) @@ -48,7 +43,6 @@ class RelayEchoClient(WebSocketClientProtocol): self.factory.ready.callback(None) else: self._received += data -# return False def onClose(self, wasClean, code, reason): print(">onClose", wasClean, code, reason) @@ -65,18 +59,15 @@ def main(reactor): f = WebSocketClientFactory("ws://127.0.0.1:4002/") f.reactor = reactor f.protocol = RelayEchoClient -## f.protocols = ["binary"] - # NB: write our own factory, probably.. f.token = "a" * 64 f.side = "0" * 16 if will_send_message else "1" * 16 f.done = Deferred() f.ready = Deferred() + proto = yield ep.connect(f) - # proto_d = ep.connect(f) - # print("proto_d", proto_d) - # proto = yield proto_d print("proto", proto) yield f.ready + print("ready") if will_send_message: for _ in range(5):