Rev943, Less verbose logging by default, Load ZeroBundle SSL lib, Log loaded SSL lib
This commit is contained in:
parent
1d6f56c676
commit
dba42f5f5e
7 changed files with 44 additions and 28 deletions
|
@ -8,7 +8,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.3.6"
|
||||
self.rev = 938
|
||||
self.rev = 943
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.config_file = "zeronet.conf"
|
||||
|
@ -116,6 +116,7 @@ class Config(object):
|
|||
action.add_argument('privatekey', help='Private key')
|
||||
|
||||
# Config parameters
|
||||
self.parser.add_argument('--verbose', help='More detailed logging', action='store_true')
|
||||
self.parser.add_argument('--debug', help='Debug mode', action='store_true')
|
||||
self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true')
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ class FileRequest(object):
|
|||
|
||||
def response(self, msg, streaming=False):
|
||||
if self.responded:
|
||||
self.log.debug("Req id %s already responded" % self.req_id)
|
||||
if config.verbose:
|
||||
self.log.debug("Req id %s already responded" % self.req_id)
|
||||
return
|
||||
if not isinstance(msg, dict): # If msg not a dict create a {"body": msg}
|
||||
msg = {"body": msg}
|
||||
|
@ -113,10 +114,11 @@ class FileRequest(object):
|
|||
else:
|
||||
peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True) # Add or get peer
|
||||
if peer:
|
||||
self.log.debug(
|
||||
"Same version, adding new peer for locked files: %s, tasks: %s" %
|
||||
(peer.key, len(site.worker_manager.tasks))
|
||||
)
|
||||
if config.verbose:
|
||||
self.log.debug(
|
||||
"Same version, adding new peer for locked files: %s, tasks: %s" %
|
||||
(peer.key, len(site.worker_manager.tasks))
|
||||
)
|
||||
for task in site.worker_manager.tasks: # New peer add to every ongoing task
|
||||
if task["peers"]:
|
||||
# Download file from this peer too if its peer locked
|
||||
|
@ -248,10 +250,11 @@ class FileRequest(object):
|
|||
|
||||
if added:
|
||||
site.worker_manager.onPeers()
|
||||
self.log.debug(
|
||||
"Added %s peers to %s using pex, sending back %s" %
|
||||
(added, site, len(packed_peers["ip4"]) + len(packed_peers["onion"]))
|
||||
)
|
||||
if config.verbose:
|
||||
self.log.debug(
|
||||
"Added %s peers to %s using pex, sending back %s" %
|
||||
(added, site, len(packed_peers["ip4"]) + len(packed_peers["onion"]))
|
||||
)
|
||||
|
||||
back = {}
|
||||
if packed_peers["ip4"]:
|
||||
|
@ -316,10 +319,11 @@ class FileRequest(object):
|
|||
if hash_id not in back:
|
||||
back[hash_id] = []
|
||||
back[hash_id].append(helper.packAddress(my_ip, self.server.port)) # Add myself
|
||||
self.log.debug(
|
||||
"Found: %s/%s" %
|
||||
(len(back), len(params["hash_ids"]))
|
||||
)
|
||||
if config.verbose:
|
||||
self.log.debug(
|
||||
"Found: %s/%s" %
|
||||
(len(back), len(params["hash_ids"]))
|
||||
)
|
||||
self.response({"peers": back})
|
||||
|
||||
def actionSetHashfield(self, params):
|
||||
|
|
|
@ -26,13 +26,14 @@ class FileServer(ConnectionServer):
|
|||
|
||||
# Handle request to fileserver
|
||||
def handleRequest(self, connection, message):
|
||||
if "params" in message:
|
||||
self.log.debug(
|
||||
"FileRequest: %s %s %s %s" %
|
||||
(str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path"))
|
||||
)
|
||||
else:
|
||||
self.log.debug("FileRequest: %s %s" % (str(connection), message["cmd"]))
|
||||
if config.verbose:
|
||||
if "params" in message:
|
||||
self.log.debug(
|
||||
"FileRequest: %s %s %s %s" %
|
||||
(str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path"))
|
||||
)
|
||||
else:
|
||||
self.log.debug("FileRequest: %s %s" % (str(connection), message["cmd"]))
|
||||
req = FileRequest(self, connection)
|
||||
req.route(message["cmd"], message.get("req_id"), message.get("params"))
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ class Peer(object):
|
|||
self.download_time = 0 # Time spent to download
|
||||
|
||||
def log(self, text):
|
||||
if not config.verbose:
|
||||
return # Only log if we are in debug mode
|
||||
if self.site:
|
||||
self.site.log.debug("%s:%s %s" % (self.ip, self.port, text))
|
||||
else:
|
||||
|
@ -107,8 +109,7 @@ class Peer(object):
|
|||
self.onConnectionError()
|
||||
return None # Connection failed
|
||||
|
||||
if config.debug:
|
||||
self.log("Send request: %s %s" % (params.get("site", ""), cmd))
|
||||
self.log("Send request: %s %s" % (params.get("site", ""), cmd))
|
||||
|
||||
for retry in range(1, 4): # Retry 3 times
|
||||
try:
|
||||
|
|
|
@ -317,10 +317,11 @@ class SiteStorage:
|
|||
bad_files.append(file_inner_path)
|
||||
self.log.debug("[OPTIONAL CHANGED] %s" % file_inner_path)
|
||||
|
||||
self.log.debug(
|
||||
"%s verified: %s, quick: %s, bad: %s, optionals: +%s -%s" %
|
||||
(content_inner_path, len(content["files"]), quick_check, bad_files, optional_added, optional_removed)
|
||||
)
|
||||
if config.verbose:
|
||||
self.log.debug(
|
||||
"%s verified: %s, quick: %s, bad: %s, optionals: +%s -%s" %
|
||||
(content_inner_path, len(content["files"]), quick_check, bad_files, optional_added, optional_removed)
|
||||
)
|
||||
|
||||
return bad_files
|
||||
|
||||
|
|
|
@ -199,12 +199,15 @@ def openLibrary():
|
|||
dll_path = "src/lib/opensslVerify/libeay32.dll"
|
||||
elif sys.platform == "cygwin":
|
||||
dll_path = "/bin/cygcrypto-1.0.0.dll"
|
||||
elif os.path.isfile("../lib/libcrypto.so"): # ZeroBundle
|
||||
dll_path = "../lib/libcrypto.so"
|
||||
else:
|
||||
dll_path = "/usr/local/ssl/lib/libcrypto.so"
|
||||
ssl = _OpenSSL(dll_path)
|
||||
assert ssl
|
||||
except Exception, err:
|
||||
ssl = _OpenSSL(ctypes.util.find_library('ssl') or ctypes.util.find_library('crypto') or ctypes.util.find_library('libcrypto') or 'libeay32')
|
||||
logging.debug("opensslVerify loaded: %s", ssl._lib)
|
||||
|
||||
openLibrary()
|
||||
openssl_version = "%.9X" % ssl._lib.SSLeay()
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
import sys
|
||||
import ctypes
|
||||
import logging
|
||||
import os
|
||||
|
||||
OpenSSL = None
|
||||
|
||||
|
@ -435,6 +437,8 @@ def openLibrary():
|
|||
dll_path = "src/lib/opensslVerify/libeay32.dll"
|
||||
elif sys.platform == "cygwin":
|
||||
dll_path = "/bin/cygcrypto-1.0.0.dll"
|
||||
elif os.path.isfile("../lib/libcrypto.so"): # ZeroBundle
|
||||
dll_path = "../lib/libcrypto.so"
|
||||
else:
|
||||
dll_path = "/usr/local/ssl/lib/libcrypto.so"
|
||||
ssl = _OpenSSL(dll_path)
|
||||
|
@ -442,6 +446,7 @@ def openLibrary():
|
|||
except Exception, err:
|
||||
ssl = _OpenSSL(ctypes.util.find_library('ssl') or ctypes.util.find_library('crypto') or ctypes.util.find_library('libcrypto') or 'libeay32')
|
||||
OpenSSL = ssl
|
||||
logging.debug("pyelliptic loaded: %s", ssl._lib)
|
||||
|
||||
|
||||
def closeLibrary():
|
||||
|
|
Loading…
Reference in a new issue