transit server: respect --blur-usage= by not logging connections
This commit is contained in:
parent
af79897fc2
commit
7d995ca1d5
|
@ -105,7 +105,7 @@ class RelayServer(service.MultiService):
|
||||||
log.msg("Wormhole relay server (Rendezvous and Transit) running")
|
log.msg("Wormhole relay server (Rendezvous and Transit) running")
|
||||||
if self._blur_usage:
|
if self._blur_usage:
|
||||||
log.msg("blurring access times to %d seconds" % self._blur_usage)
|
log.msg("blurring access times to %d seconds" % self._blur_usage)
|
||||||
log.msg("not logging HTTP requests")
|
log.msg("not logging HTTP requests or Transit connections")
|
||||||
else:
|
else:
|
||||||
log.msg("not blurring access times")
|
log.msg("not blurring access times")
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ class TransitConnection(protocol.Protocol):
|
||||||
|
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
self._started = time.time()
|
self._started = time.time()
|
||||||
|
self._log_requests = self.factory._log_requests
|
||||||
|
|
||||||
def dataReceived(self, data):
|
def dataReceived(self, data):
|
||||||
if self._sent_ok:
|
if self._sent_ok:
|
||||||
|
@ -59,6 +60,7 @@ class TransitConnection(protocol.Protocol):
|
||||||
|
|
||||||
if self._got_token: # but not yet sent_ok
|
if self._got_token: # but not yet sent_ok
|
||||||
self.transport.write(b"impatient\n")
|
self.transport.write(b"impatient\n")
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transit impatience failure")
|
log.msg("transit impatience failure")
|
||||||
return self.disconnect() # impatience yields failure
|
return self.disconnect() # impatience yields failure
|
||||||
|
|
||||||
|
@ -75,6 +77,7 @@ class TransitConnection(protocol.Protocol):
|
||||||
# handshake until we've said go
|
# handshake until we've said go
|
||||||
if len(buf) > handshake_len:
|
if len(buf) > handshake_len:
|
||||||
self.transport.write(b"impatient\n")
|
self.transport.write(b"impatient\n")
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transit impatience failure")
|
log.msg("transit impatience failure")
|
||||||
return self.disconnect() # impatience yields failure
|
return self.disconnect() # impatience yields failure
|
||||||
return self._got_handshake(token, None)
|
return self._got_handshake(token, None)
|
||||||
|
@ -83,11 +86,13 @@ class TransitConnection(protocol.Protocol):
|
||||||
if new == "yes":
|
if new == "yes":
|
||||||
if len(buf) > handshake_len:
|
if len(buf) > handshake_len:
|
||||||
self.transport.write(b"impatient\n")
|
self.transport.write(b"impatient\n")
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transit impatience failure")
|
log.msg("transit impatience failure")
|
||||||
return self.disconnect() # impatience yields failure
|
return self.disconnect() # impatience yields failure
|
||||||
return self._got_handshake(token, side)
|
return self._got_handshake(token, side)
|
||||||
if (old == "no" and new == "no"):
|
if (old == "no" and new == "no"):
|
||||||
self.transport.write(b"bad handshake\n")
|
self.transport.write(b"bad handshake\n")
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transit handshake failure")
|
log.msg("transit handshake failure")
|
||||||
return self.disconnect() # incorrectness yields failure
|
return self.disconnect() # incorrectness yields failure
|
||||||
# else we'll keep waiting
|
# else we'll keep waiting
|
||||||
|
@ -142,6 +147,7 @@ class TransitConnection(protocol.Protocol):
|
||||||
# there will be two producer/consumer pairs.
|
# there will be two producer/consumer pairs.
|
||||||
|
|
||||||
def buddy_disconnected(self):
|
def buddy_disconnected(self):
|
||||||
|
if self._log_requests:
|
||||||
log.msg("buddy_disconnected %s" % self.describeToken())
|
log.msg("buddy_disconnected %s" % self.describeToken())
|
||||||
self._buddy = None
|
self._buddy = None
|
||||||
self.transport.loseConnection()
|
self.transport.loseConnection()
|
||||||
|
@ -219,6 +225,7 @@ class Transit(protocol.ServerFactory, service.MultiService):
|
||||||
service.MultiService.__init__(self)
|
service.MultiService.__init__(self)
|
||||||
self._db = db
|
self._db = db
|
||||||
self._blur_usage = blur_usage
|
self._blur_usage = blur_usage
|
||||||
|
self._log_requests = blur_usage is None
|
||||||
self._pending_requests = {} # token -> set((side, TransitConnection))
|
self._pending_requests = {} # token -> set((side, TransitConnection))
|
||||||
self._active_connections = set() # TransitConnection
|
self._active_connections = set() # TransitConnection
|
||||||
self._counts = collections.defaultdict(int)
|
self._counts = collections.defaultdict(int)
|
||||||
|
@ -234,6 +241,7 @@ class Transit(protocol.ServerFactory, service.MultiService):
|
||||||
or (new_side is None)
|
or (new_side is None)
|
||||||
or (old_side != new_side)):
|
or (old_side != new_side)):
|
||||||
# we found a match
|
# we found a match
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transit relay 2: %s" % new_tc.describeToken())
|
log.msg("transit relay 2: %s" % new_tc.describeToken())
|
||||||
|
|
||||||
# drop and stop tracking the rest
|
# drop and stop tracking the rest
|
||||||
|
@ -248,12 +256,14 @@ class Transit(protocol.ServerFactory, service.MultiService):
|
||||||
new_tc.buddy_connected(old_tc)
|
new_tc.buddy_connected(old_tc)
|
||||||
old_tc.buddy_connected(new_tc)
|
old_tc.buddy_connected(new_tc)
|
||||||
return
|
return
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transit relay 1: %s" % new_tc.describeToken())
|
log.msg("transit relay 1: %s" % new_tc.describeToken())
|
||||||
potentials.add((new_side, new_tc))
|
potentials.add((new_side, new_tc))
|
||||||
# TODO: timer
|
# TODO: timer
|
||||||
|
|
||||||
def recordUsage(self, started, result, total_bytes,
|
def recordUsage(self, started, result, total_bytes,
|
||||||
total_time, waiting_time):
|
total_time, waiting_time):
|
||||||
|
if self._log_requests:
|
||||||
log.msg("Transit.recordUsage (%dB)" % total_bytes)
|
log.msg("Transit.recordUsage (%dB)" % total_bytes)
|
||||||
if self._blur_usage:
|
if self._blur_usage:
|
||||||
started = self._blur_usage * (started // self._blur_usage)
|
started = self._blur_usage * (started // self._blur_usage)
|
||||||
|
@ -275,10 +285,12 @@ class Transit(protocol.ServerFactory, service.MultiService):
|
||||||
self._pending_requests[token].remove(side_tc)
|
self._pending_requests[token].remove(side_tc)
|
||||||
if not self._pending_requests[token]: # set is now empty
|
if not self._pending_requests[token]: # set is now empty
|
||||||
del self._pending_requests[token]
|
del self._pending_requests[token]
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transitFinished %s" % (description,))
|
log.msg("transitFinished %s" % (description,))
|
||||||
self._active_connections.discard(tc)
|
self._active_connections.discard(tc)
|
||||||
|
|
||||||
def transitFailed(self, p):
|
def transitFailed(self, p):
|
||||||
|
if self._log_requests:
|
||||||
log.msg("transitFailed %r" % p)
|
log.msg("transitFailed %r" % p)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user