cleanup / dead code
This commit is contained in:
parent
215a0f350b
commit
60e70bac3c
|
@ -90,7 +90,7 @@ class LogToStdout(unittest.TestCase):
|
||||||
buddy_started=125,
|
buddy_started=125,
|
||||||
result="happy",
|
result="happy",
|
||||||
bytes_sent=11999,
|
bytes_sent=11999,
|
||||||
buddy_bytes=8001,
|
buddy_bytes=0,
|
||||||
)
|
)
|
||||||
print(log_file.getvalue())
|
print(log_file.getvalue())
|
||||||
self.assertEqual(json.loads(log_file.getvalue()),
|
self.assertEqual(json.loads(log_file.getvalue()),
|
||||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import print_function, unicode_literals
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from .common import ServerBase
|
from .common import ServerBase
|
||||||
from .. import transit_server
|
|
||||||
from ..server_state import (
|
from ..server_state import (
|
||||||
MemoryUsageRecorder,
|
MemoryUsageRecorder,
|
||||||
blur_size,
|
blur_size,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import re, time, json
|
import re
|
||||||
from collections import defaultdict
|
import time
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.internet import protocol
|
from twisted.internet import protocol
|
||||||
from twisted.protocols.basic import LineReceiver
|
from twisted.protocols.basic import LineReceiver
|
||||||
|
@ -16,9 +16,6 @@ from wormhole_transit_relay.server_state import (
|
||||||
TransitServerState,
|
TransitServerState,
|
||||||
PendingRequests,
|
PendingRequests,
|
||||||
ActiveConnections,
|
ActiveConnections,
|
||||||
UsageTracker,
|
|
||||||
DatabaseUsageRecorder,
|
|
||||||
LogFileUsageRecorder,
|
|
||||||
ITransitClient,
|
ITransitClient,
|
||||||
)
|
)
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer
|
||||||
|
@ -152,59 +149,9 @@ class TransitConnection(LineReceiver):
|
||||||
|
|
||||||
def connectionLost(self, reason):
|
def connectionLost(self, reason):
|
||||||
self._state.connection_lost()
|
self._state.connection_lost()
|
||||||
|
# XXX this probably resulted in a log message we've not refactored yet
|
||||||
# XXX FIXME record usage
|
# self.factory.transitFinished(self, self._got_token, self._got_side,
|
||||||
|
# self.describeToken())
|
||||||
if False:
|
|
||||||
# Record usage. There are eight cases:
|
|
||||||
# * n0: we haven't gotten a full handshake yet (empty)
|
|
||||||
# * n1: the handshake failed, not a real client (errory)
|
|
||||||
# * n2: real client disconnected before any buddy appeared (lonely)
|
|
||||||
# * n3: real client closed as redundant after buddy appears (redundant)
|
|
||||||
# * n4: real client connected first, buddy closes first (jilted)
|
|
||||||
# * n5: real client connected first, buddy close last (happy)
|
|
||||||
# * n6: real client connected last, buddy closes first (jilted)
|
|
||||||
# * n7: real client connected last, buddy closes last (happy)
|
|
||||||
|
|
||||||
# * non-connected clients (0,1,2,3) always write a usage record
|
|
||||||
# * for connected clients, whoever disconnects first gets to write the
|
|
||||||
# usage record (5, 7). The last disconnect doesn't write a record.
|
|
||||||
|
|
||||||
if self._mood == "empty": # 0
|
|
||||||
assert not self._buddy
|
|
||||||
self.factory.recordUsage(self._started, "empty", 0,
|
|
||||||
total_time, None)
|
|
||||||
elif self._mood == "errory": # 1
|
|
||||||
assert not self._buddy
|
|
||||||
self.factory.recordUsage(self._started, "errory", 0,
|
|
||||||
total_time, None)
|
|
||||||
elif self._mood == "redundant": # 3
|
|
||||||
assert not self._buddy
|
|
||||||
self.factory.recordUsage(self._started, "redundant", 0,
|
|
||||||
total_time, None)
|
|
||||||
elif self._mood == "jilted": # 4 or 6
|
|
||||||
# we were connected, but our buddy hung up on us. They record the
|
|
||||||
# usage event, we do not
|
|
||||||
pass
|
|
||||||
elif self._mood == "lonely": # 2
|
|
||||||
assert not self._buddy
|
|
||||||
self.factory.recordUsage(self._started, "lonely", 0,
|
|
||||||
total_time, None)
|
|
||||||
else: # 5 or 7
|
|
||||||
# we were connected, we hung up first. We record the event.
|
|
||||||
assert self._mood == "happy", self._mood
|
|
||||||
assert self._buddy
|
|
||||||
starts = [self._started, self._buddy._started]
|
|
||||||
total_time = finished - min(starts)
|
|
||||||
waiting_time = max(starts) - min(starts)
|
|
||||||
total_bytes = self._total_sent + self._buddy._total_sent
|
|
||||||
self.factory.recordUsage(self._started, "happy", total_bytes,
|
|
||||||
total_time, waiting_time)
|
|
||||||
|
|
||||||
if self._buddy:
|
|
||||||
self._buddy.buddy_disconnected()
|
|
||||||
# self.factory.transitFinished(self, self._got_token, self._got_side,
|
|
||||||
# self.describeToken())
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user