rev280, Fix Ubutuntu 15 gevent SSL incompatibility

This commit is contained in:
HelloZeroNet 2015-07-07 21:15:20 +02:00
parent 417c6eb96f
commit a5741704e4
2 changed files with 64 additions and 49 deletions

View File

@ -4,7 +4,7 @@ import ConfigParser
class Config(object):
def __init__(self):
self.version = "0.3.1"
self.rev = 278
self.rev = 280
self.parser = self.createArguments()
argv = sys.argv[:] # Copy command line arguments
argv = self.parseConfig(argv) # Add arguments from config file

View File

@ -4,6 +4,7 @@
import logging
from Config import config
def disableSSLCompression():
import ctypes
import ctypes.util
@ -35,8 +36,10 @@ except AttributeError:
OldSSLSocket = __ssl__.SSLSocket
class NewSSLSocket(OldSSLSocket):
# Fix SSLSocket constructor
def __init__(
self, sock, keyfile=None, certfile=None, server_side=False,
cert_reqs=__ssl__.CERT_REQUIRED, ssl_version=2, ca_certs=None,
@ -70,10 +73,22 @@ def new_sslwrap(
return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)
# Re-add sslwrap to Python 2.7.9+
if not hasattr(_ssl, 'sslwrap'):
import inspect
_ssl.sslwrap = new_sslwrap
__ssl__.SSLSocket = NewSSLSocket
logging.debug("Missing SSLwrap, readded.")
# Add SSLContext to gevent.ssl (Ubutunu 15 fix)
try:
import gevent
if not hasattr(gevent.ssl, "SSLContext"):
gevent.ssl.SSLContext = __ssl__.SSLContext
logging.debug("Missing SSLContext, readded.")
except Exception, err:
pass
logging.debug("Python SSL version: %s" % __ssl__.OPENSSL_VERSION)