rev260, Detect and fallback peers with broken SSL, Non-interactive mode for siteCreate, Pure-python msgpack is default now to make memory usage more stable

This commit is contained in:
HelloZeroNet 2015-09-02 19:15:55 +02:00
parent dd2bb8b3fb
commit d8edaeb6ac
4 changed files with 15 additions and 7 deletions

View file

@ -161,7 +161,7 @@ class Connection(object):
else:
self.port = handshake["fileserver_port"] # Set peer fileserver port
# Check if we can encrypt the connection
if handshake.get("crypt_supported"):
if handshake.get("crypt_supported") and handshake["peer_id"] not in self.server.broken_ssl_peer_ids:
if handshake.get("crypt"): # Recommended crypt by server
crypt = handshake["crypt"]
else: # Select the best supported on both sides
@ -209,8 +209,12 @@ class Connection(object):
if self.crypt and not self.sock_wrapped:
server = (self.type == "in")
self.log("Crypt in connection using: %s (server side: %s)..." % (self.crypt, server))
self.sock = CryptConnection.manager.wrapSocket(self.sock, self.crypt, server)
self.sock_wrapped = True
try:
self.sock = CryptConnection.manager.wrapSocket(self.sock, self.crypt, server)
self.sock_wrapped = True
except Exception, err:
self.log("Crypt connection error: %s, adding peerid %s as broken ssl." % (err, message["params"]["peer_id"]))
self.server.broken_ssl_peer_ids[message["params"]["peer_id"]] = True
else:
self.server.handleRequest(self, message)
else: # Old style response, no req_id definied

View file

@ -25,6 +25,7 @@ class ConnectionServer:
self.connections = [] # Connections
self.ip_incoming = {} # Incoming connections from ip in the last minute to avoid connection flood
self.broken_ssl_peer_ids = {} # Peerids of broken ssl connections
self.ips = {} # Connection by ip
self.peer_ids = {} # Connections by peer_ids
@ -150,7 +151,8 @@ class ConnectionServer:
def checkConnections(self):
while self.running:
time.sleep(60) # Sleep 1 min
self.ip_incoming = {}
self.ip_incoming = {} # Reset connected ips counter
self.broken_ssl_peer_ids = {} # Reset broken ssl peerids count
for connection in self.connections[:]: # Make a copy
idle = time.time() - max(connection.last_recv_time, connection.start_time, connection.last_message_time)