Browse Source

Remove check for ssl module

Any Python setup has it, it was only introduced to check for PyOpenSSL which is now dropped.
pull/832/head
Safihre 8 years ago
parent
commit
4fb6e3fe7b
  1. 7
      interfaces/Config/templates/config.tmpl
  2. 4
      interfaces/Config/templates/config_general.tmpl
  3. 8
      interfaces/Config/templates/config_server.tmpl
  4. 4
      interfaces/Config/templates/config_switches.tmpl
  5. 4
      interfaces/wizard/one.html
  6. 14
      sabnzbd/__init__.py
  7. 3
      sabnzbd/api.py
  8. 2
      sabnzbd/downloader.py
  9. 14
      sabnzbd/interface.py
  10. 9
      sabnzbd/misc.py
  11. 43
      sabnzbd/newswrapper.py
  12. 9
      sabnzbd/nzbstuff.py
  13. 3
      sabnzbd/rating.py
  14. 1
      sabnzbd/wizard.py

7
interfaces/Config/templates/config.tmpl

@ -34,12 +34,7 @@
<tr>
<th scope="row">OpenSSL:</th>
<td>
<!--#if $have_ssl#-->
$ssl_version &nbsp; [$ssl_protocols]
<!--#else#-->
<span class="label label-danger">$T('notAvailable')</span>
<a href="$helpuri$help_uri#no_ssl" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a>
<!--#end if#-->
$ssl_version &nbsp; [$ssl_protocols]
</td>
</tr>
<!--#if not $have_ssl_context#-->

4
interfaces/Config/templates/config_general.tmpl

@ -23,9 +23,9 @@
<input type="number" name="port" id="port" value="$port" size="8" data-original="$port" />
<span class="desc">$T('explain-port')</span>
</div>
<div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
<div class="field-pair">
<label class="config" for="enable_https">$T('opt-enable_https')</label>
<input type="checkbox" name="enable_https" id="enable_https" value="1" <!--#if int($enable_https) > 0 then 'checked="checked"' else ""#--> <!--#if int($have_ssl) == 0 then "disabled" else ""#--> />
<input type="checkbox" name="enable_https" id="enable_https" value="1" <!--#if int($enable_https) > 0 then 'checked="checked"' else ""#-->/>
<span class="desc">$T('explain-enable_https')</span>
</div>
<div class="field-pair">

8
interfaces/Config/templates/config_server.tmpl

@ -29,9 +29,9 @@
<label class="config" for="port">$T('srv-port')</label>
<input type="number" name="port" id="port" size="8" value="119" />
</div>
<div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
<div class="field-pair">
<label class="config" for="ssl">$T('srv-ssl')</label>
<input type="checkbox" name="ssl" id="ssl" value="1" <!--#if int($have_ssl) == 0 then "disabled=\"disabled\"" else ""#--> />
<input type="checkbox" name="ssl" id="ssl" value="1" />
<span class="desc">$T('explain-ssl')</span>
</div>
<!-- Tricks to avoid browser auto-fill, fixed on-submit with javascript -->
@ -149,9 +149,9 @@
<label class="config" for="port$cur">$T('srv-port')</label>
<input type="number" name="port" id="port$cur" value="$server['port']" size="8" />
</div>
<div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
<div class="field-pair">
<label class="config" for="ssl$cur">$T('srv-ssl')</label>
<input type="checkbox" name="ssl" id="ssl$cur" value="1" <!--#if int($server['ssl']) != 0 and int($have_ssl) == 1 then 'checked="checked"' else ""#--> <!--#if int($have_ssl) == 0 then "disabled=\"disabled\"" else ""#--> />
<input type="checkbox" name="ssl" id="ssl$cur" value="1" <!--#if int($server['ssl']) != 0 then 'checked="checked"' else ""#--> />
<span class="desc">$T('explain-ssl')</span>
</div>
<!-- Tricks to avoid browser auto-fill, fixed on-submit with javascript -->

4
interfaces/Config/templates/config_switches.tmpl

@ -20,9 +20,9 @@
</select>
<span class="desc">$T('explain-load_balancing')</span>
</div>
<div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
<div class="field-pair">
<label class="config" for="ssl_ciphers">$T('opt-ssl_ciphers')</label>
<input type="text" name="ssl_ciphers" id="ssl_ciphers" value="$ssl_ciphers"<!--#if int($have_ssl) == 0 then "disabled=\"disabled\"" else ""#--> />
<input type="text" name="ssl_ciphers" id="ssl_ciphers" value="$ssl_ciphers" />
<span class="desc">$T('explain-ssl_ciphers') <br>$T('readwiki')
<a href="${helpuri}advanced/ssl-ciphers" target="_blank">${helpuri}advanced/ssl-ciphers</a></span>
</div>

4
interfaces/wizard/one.html

@ -40,9 +40,7 @@
$T('srv-ssl')
</label>
<div class="col-sm-8 input-checkbox">
<input type="checkbox" id="ssl" name="ssl" value="1" <!--#if $have_ssl then '' else 'disabled'#--><!--#if $ssl == 1 then 'checked' else ''#--> data-toggle="tooltip" data-placement="right" title="$T('wizard-server-ssl-explain')"/>
<!--#if not $have_ssl then '<span class="label label-warning">OpenSSL '+$T('opt-notInstalled')+'</span>' else ''#-->
<small></small>
<input type="checkbox" id="ssl" name="ssl" value="1" data-toggle="tooltip" data-placement="right" title="$T('wizard-server-ssl-explain')"/>
</div>
</div>
<div class="form-group">

14
sabnzbd/__init__.py

@ -79,19 +79,13 @@ else:
##############################################################################
# SSL CHECKS
##############################################################################
import ssl
HAVE_SSL_CONTEXT = None
HAVE_SSL = None
try:
import ssl
HAVE_SSL = True
try:
# Test availability of SSLContext (python 2.7.9+)
ssl.SSLContext
HAVE_SSL_CONTEXT = True
except:
HAVE_SSL_CONTEXT = False
# Test availability of SSLContext (python 2.7.9+)
ssl.SSLContext
HAVE_SSL_CONTEXT = True
except:
HAVE_SSL = False
HAVE_SSL_CONTEXT = False
try:

3
sabnzbd/api.py

@ -1586,8 +1586,7 @@ def options_list(output):
'zip': sabnzbd.newsunpack.ZIP_COMMAND,
'7zip': sabnzbd.newsunpack.SEVEN_COMMAND,
'nice': sabnzbd.newsunpack.NICE_COMMAND,
'ionice': sabnzbd.newsunpack.IONICE_COMMAND,
'ssl': sabnzbd.HAVE_SSL
'ionice': sabnzbd.newsunpack.IONICE_COMMAND
})

2
sabnzbd/downloader.py

@ -226,7 +226,7 @@ class Downloader(Thread):
timeout = srv.timeout()
threads = srv.connections()
priority = srv.priority()
ssl = srv.ssl() and sabnzbd.HAVE_SSL
ssl = srv.ssl()
ssl_verify = srv.ssl_verify()
username = srv.username()
password = srv.password()

14
sabnzbd/interface.py

@ -1270,14 +1270,9 @@ class ConfigPage(object):
conf['have_yenc'] = HAVE_YENC
conf['have_sabyenc'] = HAVE_SABYENC
if sabnzbd.HAVE_SSL:
conf['have_ssl'] = 1
conf['have_ssl_context'] = sabnzbd.HAVE_SSL_CONTEXT
conf['ssl_version'] = ssl_version()
conf['ssl_protocols'] = ', '.join(ssl_protocols_labels())
else:
conf['have_ssl'] = 0
conf['have_ssl_context'] = 0
conf['have_ssl_context'] = sabnzbd.HAVE_SSL_CONTEXT
conf['ssl_version'] = ssl_version()
conf['ssl_protocols'] = ', '.join(ssl_protocols_labels())
new = {}
for svr in config.get_servers():
@ -1452,7 +1447,6 @@ class ConfigSwitches(object):
conf = build_header(self.__prim, self.__web_dir)
conf['have_ssl'] = sabnzbd.HAVE_SSL
conf['have_ssl_context'] = sabnzbd.HAVE_SSL_CONTEXT
conf['have_multicore'] = sabnzbd.WIN32 or sabnzbd.DARWIN_INTEL
conf['have_nice'] = bool(sabnzbd.newsunpack.NICE_COMMAND)
@ -1610,7 +1604,6 @@ class ConfigGeneral(object):
# Temporary fix, problem with build_header
conf['restart_req'] = sabnzbd.RESTART_REQ
conf['have_ssl'] = sabnzbd.HAVE_SSL
conf['have_ssl_context'] = sabnzbd.HAVE_SSL_CONTEXT
conf['have_cryptography'] = bool(sabnzbd.HAVE_CRYPTOGRAPHY)
@ -1790,7 +1783,6 @@ class ConfigServer(object):
new[-1]['amounts'] = to_units(t), to_units(m), to_units(w), to_units(d)
conf['servers'] = new
conf['cats'] = list_cats(default=True)
conf['have_ssl'] = sabnzbd.HAVE_SSL
conf['have_ssl_context'] = sabnzbd.HAVE_SSL_CONTEXT
template = Template(file=os.path.join(self.__web_dir, 'config_server.tmpl'),

9
sabnzbd/misc.py

@ -1448,15 +1448,6 @@ def is_writable(path):
return True
def format_source_url(url):
""" Format URL suitable for 'Source' stage """
if sabnzbd.HAVE_SSL:
prot = 'https'
else:
prot = 'http:'
return url
def get_base_url(url):
""" Return only the true root domain for the favicon, so api.oznzb.com -> oznzb.com
But also api.althub.co.za -> althub.co.za

43
sabnzbd/newswrapper.py

@ -27,39 +27,22 @@ import time
import logging
import re
import select
import ssl
import sabnzbd
from sabnzbd.constants import *
import sabnzbd.cfg
from sabnzbd.misc import nntp_to_msg
import threading
_RLock = threading.RLock
del threading
# Import SSL if available
if sabnzbd.HAVE_SSL:
import ssl
if sabnzbd.HAVE_SSL_CONTEXT:
WantReadError = ssl.SSLWantReadError
CertificateError = ssl.CertificateError
else:
WantReadError = ssl.SSLError
CertificateError = ssl.SSLError
# Have to make errors available under Python <2.7.9
if sabnzbd.HAVE_SSL_CONTEXT:
WantReadError = ssl.SSLWantReadError
CertificateError = ssl.CertificateError
else:
# Dummy class so this exception is ignored by clients without ssl installed
class WantReadError(Exception):
def __init__(self, value):
self.parameter = value
def __str__(self):
return repr(self.parameter)
class CertificateError(Exception):
def __init__(self, value):
self.parameter = value
def __str__(self):
return repr(self.parameter)
WantReadError = ssl.SSLError
CertificateError = ssl.SSLError
# Set pre-defined socket timeout
socket.setdefaulttimeout(DEF_TIMEOUT)
# getaddrinfo() can be very slow. In some situations this can lead
@ -134,7 +117,7 @@ def con(sock, host, port, sslenabled, write_fds, nntp):
try:
sock.connect((host, port))
sock.setblocking(0)
if sslenabled and sabnzbd.HAVE_SSL:
if sslenabled:
# Log SSL/TLS info
logging.info("%s@%s: Connected using %s (%s)",
nntp.nw.thrdnum, nntp.nw.server.host, get_ssl_version(sock), sock.cipher()[0])
@ -205,7 +188,7 @@ class NNTP(object):
if probablyipv6(host):
af = socket.AF_INET6
if sslenabled and sabnzbd.HAVE_SSL:
if sslenabled:
# Use context or just wrapper
if sabnzbd.HAVE_SSL_CONTEXT:
# Setup the SSL socket
@ -229,10 +212,6 @@ class NNTP(object):
ciphers = sabnzbd.cfg.ssl_ciphers() if sabnzbd.cfg.ssl_ciphers() else None
# Use a regular wrapper, no certificate validation
self.sock = ssl.wrap_socket(socket.socket(af, socktype, proto), ciphers=ciphers)
elif sslenabled and not sabnzbd.HAVE_SSL:
logging.error(T('Error importing OpenSSL module. Connecting with NON-SSL'))
self.sock = socket.socket(af, socktype, proto)
else:
self.sock = socket.socket(af, socktype, proto)
@ -245,7 +224,7 @@ class NNTP(object):
# if blocking (server test) only wait for 15 seconds during connect until timeout
self.sock.settimeout(15)
self.sock.connect((self.host, self.port))
if sslenabled and sabnzbd.HAVE_SSL:
if sslenabled:
# Log SSL/TLS info
logging.info("%s@%s: Connected using %s (%s)",
self.nw.thrdnum, self.nw.server.host, get_ssl_version(self.sock), self.sock.cipher()[0])

9
sabnzbd/nzbstuff.py

@ -46,10 +46,9 @@ from sabnzbd.constants import sample_match, GIGI, ATTRIB_FILE, JOB_ADMIN, \
PAUSED_PRIORITY, TOP_PRIORITY, DUP_PRIORITY, REPAIR_PRIORITY, \
RENAMES_FILE, Status, PNFO
from sabnzbd.misc import to_units, cat_to_opts, cat_convert, sanitize_foldername, \
get_unique_path, get_admin_path, remove_all, format_source_url, \
sanitize_filename, globber_full, sanitize_foldername, int_conv, \
set_permissions, format_time_string, long_path, trim_win_path, \
fix_unix_encoding, calc_age
get_unique_path, get_admin_path, remove_all, sanitize_filename, globber_full, \
sanitize_foldername, int_conv, set_permissions, format_time_string, long_path, \
trim_win_path, fix_unix_encoding, calc_age
from sabnzbd.decorators import synchronized, IO_LOCK
import sabnzbd.config as config
import sabnzbd.cfg as cfg
@ -1324,7 +1323,7 @@ class NzbObject(TryList):
msg = u''.join((msg1, msg2, msg3, msg4, msg5, ))
self.set_unpack_info('Download', msg, unique=True)
if self.url:
self.set_unpack_info('Source', format_source_url(self.url), unique=True)
self.set_unpack_info('Source', self.url, unique=True)
servers = config.get_servers()
if len(self.servercount) > 0:
msgs = ['%s=%sB' % (servers[server].displayname(), to_units(self.servercount[server])) for server in self.servercount if server in servers]

3
sabnzbd/rating.py

@ -133,9 +133,6 @@ class Rating(Thread):
self.ratings = {}
self.nzo_indexer_map = {}
Thread.__init__(self)
if not sabnzbd.HAVE_SSL:
logging.warning(T('Ratings server requires secure connection'))
self.stop()
def stop(self):
self.shutdown = True

1
sabnzbd/wizard.py

@ -96,7 +96,6 @@ class Wizard(object):
info['language'] = cfg.language()
info['active_lang'] = info['language']
info['T'] = Ttemplate
info['have_ssl'] = bool(sabnzbd.HAVE_SSL)
servers = config.get_servers()
if not servers:

Loading…
Cancel
Save