honour log_requests as original code did
This commit is contained in:
parent
1a1947d7e9
commit
aa58b85ace
|
@ -1,6 +1,7 @@
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
import automat
|
import automat
|
||||||
|
from twisted.python import log
|
||||||
from zope.interface import (
|
from zope.interface import (
|
||||||
Interface,
|
Interface,
|
||||||
Attribute,
|
Attribute,
|
||||||
|
@ -265,6 +266,8 @@ class TransitServerState(object):
|
||||||
def _send_bad(self):
|
def _send_bad(self):
|
||||||
self._mood = "errory"
|
self._mood = "errory"
|
||||||
self._client.send(b"bad handshake\n")
|
self._client.send(b"bad handshake\n")
|
||||||
|
if self._client.factory.log_requests:
|
||||||
|
log.msg("transit handshake failure")
|
||||||
|
|
||||||
@_machine.output()
|
@_machine.output()
|
||||||
def _send_ok(self):
|
def _send_ok(self):
|
||||||
|
@ -273,6 +276,8 @@ class TransitServerState(object):
|
||||||
@_machine.output()
|
@_machine.output()
|
||||||
def _send_impatient(self):
|
def _send_impatient(self):
|
||||||
self._client.send(b"impatient\n")
|
self._client.send(b"impatient\n")
|
||||||
|
if self._client.factory.log_requests:
|
||||||
|
log.msg("transit impatience failure")
|
||||||
|
|
||||||
@_machine.output()
|
@_machine.output()
|
||||||
def _count_bytes(self, data):
|
def _count_bytes(self, data):
|
||||||
|
|
|
@ -59,6 +59,7 @@ def makeService(config, reactor=reactor):
|
||||||
transit = transit_server.Transit(usage, reactor.seconds)
|
transit = transit_server.Transit(usage, reactor.seconds)
|
||||||
tcp_factory = protocol.ServerFactory()
|
tcp_factory = protocol.ServerFactory()
|
||||||
tcp_factory.protocol = transit_server.TransitConnection
|
tcp_factory.protocol = transit_server.TransitConnection
|
||||||
|
tcp_factory.log_requests = False
|
||||||
|
|
||||||
if ws_ep is not None:
|
if ws_ep is not None:
|
||||||
ws_url = config["websocket-url"]
|
ws_url = config["websocket-url"]
|
||||||
|
@ -71,6 +72,7 @@ def makeService(config, reactor=reactor):
|
||||||
ws_factory = WebSocketServerFactory(ws_url)
|
ws_factory = WebSocketServerFactory(ws_url)
|
||||||
ws_factory.protocol = transit_server.WebSocketTransitConnection
|
ws_factory.protocol = transit_server.WebSocketTransitConnection
|
||||||
ws_factory.transit = transit
|
ws_factory.transit = transit
|
||||||
|
ws_factory.log_requests = False
|
||||||
|
|
||||||
tcp_factory.transit = transit
|
tcp_factory.transit = transit
|
||||||
parent = MultiService()
|
parent = MultiService()
|
||||||
|
|
|
@ -88,6 +88,7 @@ class ServerBase:
|
||||||
server_factory = ServerFactory()
|
server_factory = ServerFactory()
|
||||||
server_factory.protocol = TransitConnection
|
server_factory.protocol = TransitConnection
|
||||||
server_factory.transit = self._transit_server
|
server_factory.transit = self._transit_server
|
||||||
|
server_factory.log_requests = self.log_requests
|
||||||
server_protocol = server_factory.buildProtocol(('127.0.0.1', 0))
|
server_protocol = server_factory.buildProtocol(('127.0.0.1', 0))
|
||||||
|
|
||||||
@implementer(IRelayTestClient)
|
@implementer(IRelayTestClient)
|
||||||
|
|
|
@ -440,6 +440,7 @@ class TransitWebSockets(_Transit, ServerBase, unittest.TestCase):
|
||||||
ws_factory = WebSocketServerFactory("ws://localhost:4002")
|
ws_factory = WebSocketServerFactory("ws://localhost:4002")
|
||||||
ws_factory.protocol = WebSocketTransitConnection
|
ws_factory.protocol = WebSocketTransitConnection
|
||||||
ws_factory.transit = self._transit_server
|
ws_factory.transit = self._transit_server
|
||||||
|
ws_factory.log_requests = self.log_requests
|
||||||
ws_protocol = ws_factory.buildProtocol(('127.0.0.1', 0))
|
ws_protocol = ws_factory.buildProtocol(('127.0.0.1', 0))
|
||||||
|
|
||||||
@implementer(IRelayTestClient)
|
@implementer(IRelayTestClient)
|
||||||
|
@ -656,6 +657,7 @@ class UsageWebSockets(Usage):
|
||||||
ws_factory = WebSocketServerFactory("ws://localhost:4002")
|
ws_factory = WebSocketServerFactory("ws://localhost:4002")
|
||||||
ws_factory.protocol = WebSocketTransitConnection
|
ws_factory.protocol = WebSocketTransitConnection
|
||||||
ws_factory.transit = self._transit_server
|
ws_factory.transit = self._transit_server
|
||||||
|
ws_factory.log_requests = self.log_requests
|
||||||
ws_protocol = ws_factory.buildProtocol(('127.0.0.1', 0))
|
ws_protocol = ws_factory.buildProtocol(('127.0.0.1', 0))
|
||||||
|
|
||||||
class TransitWebSocketClientProtocol(WebSocketClientProtocol):
|
class TransitWebSocketClientProtocol(WebSocketClientProtocol):
|
||||||
|
|
|
@ -53,7 +53,8 @@ class TransitConnection(LineReceiver):
|
||||||
ITransitClient API
|
ITransitClient API
|
||||||
"""
|
"""
|
||||||
if self._buddy is not None:
|
if self._buddy is not None:
|
||||||
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
if self.factory.log_requests:
|
||||||
|
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
||||||
self._buddy._client.disconnect()
|
self._buddy._client.disconnect()
|
||||||
self._buddy = None
|
self._buddy = None
|
||||||
|
|
||||||
|
@ -203,7 +204,8 @@ class WebSocketTransitConnection(WebSocketServerProtocol):
|
||||||
ITransitClient API
|
ITransitClient API
|
||||||
"""
|
"""
|
||||||
if self._buddy is not None:
|
if self._buddy is not None:
|
||||||
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
if self.factory.log_requests:
|
||||||
|
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
||||||
self._buddy._client.disconnect()
|
self._buddy._client.disconnect()
|
||||||
self._buddy = None
|
self._buddy = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user