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:
parent
dd2bb8b3fb
commit
d8edaeb6ac
4 changed files with 15 additions and 7 deletions
|
@ -8,7 +8,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.3.2"
|
||||
self.rev = 357
|
||||
self.rev = 360
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.createParser()
|
||||
|
@ -103,6 +103,8 @@ class Config(object):
|
|||
self.parser.add_argument('--debug', help='Debug mode', action='store_true')
|
||||
self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true')
|
||||
|
||||
self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true')
|
||||
|
||||
self.parser.add_argument('--config_file', help='Path of config file', default="zeronet.conf", metavar="path")
|
||||
self.parser.add_argument('--data_dir', help='Path of data directory', default="data", metavar="path")
|
||||
self.parser.add_argument('--log_dir', help='Path of logging directory', default="log", metavar="path")
|
||||
|
@ -131,7 +133,7 @@ class Config(object):
|
|||
self.parser.add_argument('--stream_downloads', help='Stream download directly to files (experimental)',
|
||||
type='bool', choices=[True, False], default=False)
|
||||
self.parser.add_argument("--msgpack_purepython", help='Use less memory, but a bit more CPU power',
|
||||
type='bool', choices=[True, False], default=False)
|
||||
type='bool', choices=[True, False], default=True)
|
||||
|
||||
self.parser.add_argument('--coffeescript_compiler', help='Coffeescript compiler for developing', default=coffeescript,
|
||||
metavar='executable_path')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class Actions(object):
|
|||
logging.info("Site address: %s" % address)
|
||||
logging.info("----------------------------------------------------------------------")
|
||||
|
||||
while True:
|
||||
while True and not config.batch:
|
||||
if raw_input("? Have you secured your private key? (yes, no) > ").lower() == "yes":
|
||||
break
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue