Browse Source

Warning when we refuse connection to unlisted hostname

tags/2.3.3Beta1
Safihre 7 years ago
parent
commit
3fd9e85236
  1. 12
      po/main/SABnzbd.pot
  2. 32
      sabnzbd/interface.py

12
po/main/SABnzbd.pot

@ -12,7 +12,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ASCII\n"
"Content-Transfer-Encoding: 7bit\n"
"POT-Creation-Date: 2018-03-12 16:33+W. Europe Standard Time\n"
"POT-Creation-Date: 2018-03-15 09:00+W. Europe Standard Time\n"
"Generated-By: pygettext.py 1.5\n"
@ -105,7 +105,7 @@ msgid "Error"
msgstr ""
#: SABnzbd.py # sabnzbd/interface.py # sabnzbd/interface.py
#: sabnzbd/osxmenu.py # sabnzbd/wizard.py
#: sabnzbd/interface.py # sabnzbd/osxmenu.py
msgid "SABnzbd shutdown finished"
msgstr ""
@ -584,6 +584,10 @@ msgid "Server address \"%s:%s\" is not valid."
msgstr ""
#: sabnzbd/interface.py
msgid "Refused connection with hostname \"%s\" from:"
msgstr ""
#: sabnzbd/interface.py
msgid "User logged in to the web interface"
msgstr ""
@ -591,7 +595,7 @@ msgstr ""
msgid "User logged in"
msgstr ""
#: sabnzbd/interface.py [Warning message]
#: sabnzbd/interface.py
msgid "Missing Session key"
msgstr ""
@ -599,7 +603,7 @@ msgstr ""
msgid "Error: Session Key Required"
msgstr ""
#: sabnzbd/interface.py [Warning message] # sabnzbd/interface.py
#: sabnzbd/interface.py # sabnzbd/interface.py
msgid "Error: Session Key Incorrect"
msgstr ""

32
sabnzbd/interface.py

@ -177,7 +177,7 @@ def check_hostname():
return True
# Ohoh, bad
logging.debug('Refused connection from %s with hostname %s', cherrypy.request.remote.ip, host)
log_warning_and_ip(T('Refused connection with hostname "%s" from:') % host)
return False
@ -315,10 +315,10 @@ def check_session(kwargs):
key = kwargs.get('apikey')
msg = None
if not key:
logging.warning(T('Missing Session key'))
log_warning_and_ip(T('Missing Session key'))
msg = T('Error: Session Key Required')
elif key != cfg.api_key():
logging.warning(T('Error: Session Key Incorrect'))
log_warning_and_ip(T('Error: Session Key Incorrect'))
msg = T('Error: Session Key Incorrect')
return msg
@ -327,15 +327,6 @@ def check_apikey(kwargs, nokey=False):
""" Check api key or nzbkey
Return None when OK, otherwise an error message
"""
def log_warning(txt):
# Was it proxy forwarded?
xff = cherrypy.request.headers.get('X-Forwarded-For')
if xff:
txt = '%s %s (X-Forwarded-For: %s)>%s' % (txt, cherrypy.request.remote.ip, xff, cherrypy.request.headers.get('User-Agent', '??'))
else:
txt = '%s %s>%s' % (txt, cherrypy.request.remote.ip, cherrypy.request.headers.get('User-Agent', '??'))
logging.warning('%s', txt)
output = kwargs.get('output')
mode = kwargs.get('mode', '')
name = kwargs.get('name', '')
@ -356,14 +347,14 @@ def check_apikey(kwargs, nokey=False):
key = kwargs.get('session')
if not key:
if cfg.api_warnings():
log_warning(T('API Key missing, please enter the api key from Config->General into your 3rd party program:'))
log_warning_and_ip(T('API Key missing, please enter the api key from Config->General into your 3rd party program:'))
return report(output, 'API Key Required')
elif req_access == 1 and key == cfg.nzb_key():
return None
elif key == cfg.api_key():
return None
else:
log_warning(T('API Key incorrect, Use the api key from Config->General in your 3rd party program:'))
log_warning_and_ip(T('API Key incorrect, Use the api key from Config->General in your 3rd party program:'))
return report(output, 'API Key Incorrect')
# No active APIKEY, check web credentials instead
@ -372,11 +363,22 @@ def check_apikey(kwargs, nokey=False):
pass
else:
if cfg.api_warnings():
log_warning(T('Authentication missing, please enter username/password from Config->General into your 3rd party program:'))
log_warning_and_ip(T('Authentication missing, please enter username/password from Config->General into your 3rd party program:'))
return report(output, 'Missing authentication')
return None
def log_warning_and_ip(txt):
""" Include the IP and the Proxy-IP for warnings """
# Was it proxy forwarded?
xff = cherrypy.request.headers.get('X-Forwarded-For')
if xff:
txt = '%s %s (X-Forwarded-For: %s)>%s' % (txt, cherrypy.request.remote.ip, xff, cherrypy.request.headers.get('User-Agent', '??'))
else:
txt = '%s %s>%s' % (txt, cherrypy.request.remote.ip, cherrypy.request.headers.get('User-Agent', '??'))
logging.warning('%s', txt)
##############################################################################
class MainPage(object):

Loading…
Cancel
Save