From 3869cb9bf36b4efba90461f4f7a57dd4eb763aa2 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sun, 2 Sep 2018 02:19:51 +0200 Subject: [PATCH] Show incoming and outgoing connection separatley in stats page --- plugins/Stats/StatsPlugin.py | 4 ++-- src/Connection/ConnectionServer.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/Stats/StatsPlugin.py b/plugins/Stats/StatsPlugin.py index e165bf62..1f3ae99a 100644 --- a/plugins/Stats/StatsPlugin.py +++ b/plugins/Stats/StatsPlugin.py @@ -93,8 +93,8 @@ class UiRequestPlugin(object): yield "
" # Connections - yield "Connections (%s, total made: %s):
" % ( - len(main.file_server.connections), main.file_server.last_connection_id + yield "Connections (%s, total made: %s, in: %s, out: %s):
" % ( + len(main.file_server.connections), main.file_server.last_connection_id, main.file_server.num_incoming, main.file_server.num_outgoing ) yield "" yield "" diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index 9959abff..1852437f 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -45,6 +45,9 @@ class ConnectionServer(object): self.num_recv = 0 self.num_sent = 0 + self.num_incoming = 0 + self.num_outgoing = 0 + # Bittorrent style peerid self.peer_id = "-UT3530-%s" % CryptHash.random(12, "base64") @@ -96,6 +99,7 @@ class ConnectionServer(object): def handleIncomingConnection(self, sock, addr): ip, port = addr + self.num_incoming += 1 # Connection flood protection if ip in self.ip_incoming and ip not in self.whitelist: @@ -164,6 +168,7 @@ class ConnectionServer(object): connection = Connection(self, ip, port, target_onion=site_onion, is_tracker_connection=is_tracker_connection) else: connection = Connection(self, ip, port, is_tracker_connection=is_tracker_connection) + self.num_outgoing += 1 self.ips[key] = connection self.connections.append(connection) succ = connection.connect()
id type ip open crypt pingbuff bad idle open delay cpu out in last sent