diff --git a/plugins/Stats/StatsPlugin.py b/plugins/Stats/StatsPlugin.py index 32fd06c5..cdd09d8f 100644 --- a/plugins/Stats/StatsPlugin.py +++ b/plugins/Stats/StatsPlugin.py @@ -73,14 +73,15 @@ class UiRequestPlugin(object): import main # Connections - yield "Connections (%s, total made: %s, in: %s, out: %s):
" % ( - len(main.file_server.connections), main.file_server.last_connection_id, + yield "Connections (%s, current version: %s, total made: %s, in: %s, out: %s):
" % ( + len(main.file_server.connections), main.file_server.last_connection_id_current_version, main.file_server.last_connection_id, main.file_server.num_incoming, main.file_server.num_outgoing ) yield "" yield "" yield "" - for connection in main.file_server.connections: + connections = sorted(main.file_server.connections, key=lambda connection: connection.handshake.get("rev", 0), reverse=True) + for connection in connections: if "cipher" in dir(connection.sock): cipher = connection.sock.cipher()[0] tls_version = connection.sock.version() @@ -364,8 +365,14 @@ class UiRequestPlugin(object): self.sendHeader() if "Multiuser" in PluginManager.plugin_manager.plugin_names and not config.multiuser_local: - yield "This function is disabled on this proxy" - return + if 'access_key' not in self.get.keys(): + yield "This function is disabled on this proxy" + return + else: + access_key = self.get["access_key"] + if access_key != config.access_key: + yield "This function is disabled on this proxy" + return s = time.time() diff --git a/src/Config.py b/src/Config.py index 9bfcf96d..7555f65d 100644 --- a/src/Config.py +++ b/src/Config.py @@ -13,7 +13,7 @@ import time class Config(object): def __init__(self, argv): - self.version = "0.7.5" + self.version = "0.7.6-internal" self.rev = 4560 self.argv = argv self.action = None @@ -79,6 +79,8 @@ class Config(object): # Create command line arguments def createArguments(self): + from Crypt import CryptHash + access_key_default = CryptHash.random(24, "base64") # Used to allow restrited plugins when multiuser plugin is enabled trackers = [ "zero://boot3rdez4rzn36x.onion:15441", "http://open.acgnxtracker.com:80/announce", # DE @@ -97,9 +99,6 @@ class Config(object): "udp://tracker.0x.tf:6969/announce", "udp://tracker.zerobytes.xyz:1337/announce", "udp://vibe.sleepyinternetfun.xyz:1738/announce", - "udp://tracker.bitsearch.to:1337/announce", - "udp://jeremylee.sh:6969/announce", - "udp://tracker.pomf.se:80/announce", "udp://www.torrent.eu.org:451/announce", "zero://k5w77dozo3hy5zualyhni6vrh73iwfkaofa64abbilwyhhd3wgenbjqd.onion:15441", "zero://2kcb2fqesyaevc4lntogupa4mkdssth2ypfwczd2ov5a3zo6ytwwbayd.onion:15441", @@ -271,6 +270,7 @@ class Config(object): metavar='address') self.parser.add_argument('--updatesite', help='Source code update site', default='1Update8crprmciJHwp2WXqkx2c4iYp18', metavar='address') + self.parser.add_argument('--access_key', help='Plugin access key default: Random key generated at startup', default=access_key_default, metavar='key') self.parser.add_argument('--dist_type', help='Type of installed distribution', default='source') self.parser.add_argument('--size_limit', help='Default site size limit in MB', default=10, type=int, metavar='limit') diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index 8d377aca..090d96a6 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -30,7 +30,8 @@ class ConnectionServer(object): port = 15441 self.ip = ip self.port = port - self.last_connection_id = 1 # Connection id incrementer + self.last_connection_id = 0 # Connection id incrementer + self.last_connection_id_current_version = 0 # Connection id incrementer for current client version self.log = logging.getLogger("ConnServer") self.port_opened = {} self.peer_blacklist = SiteManager.peer_blacklist @@ -155,6 +156,9 @@ class ConnectionServer(object): connection = Connection(self, ip, port, sock) self.connections.append(connection) + rev = connection.handshake.get("rev", 0) + if rev > 0 and rev == config.rev: + self.last_connection_id_current_version += 1 if ip not in config.ip_local: self.ips[ip] = connection connection.handleIncomingConnection(sock) @@ -219,6 +223,10 @@ class ConnectionServer(object): if not succ: connection.close("Connection event return error") raise Exception("Connection event return error") + else: + rev = connection.handshake.get("rev", 0) + if rev > 0 and rev == config.rev: + self.last_connection_id_current_version += 1 except Exception as err: connection.close("%s Connect error: %s" % (ip, Debug.formatException(err)))
id type ip open crypt pingbuff bad idle open delay cpu out in last sentwait version time sites