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