merged main branch

This commit is contained in:
Goffi 2016-06-24 22:41:28 +02:00
commit a28bb7be8f
11 changed files with 323 additions and 35 deletions

View file

@ -23,6 +23,7 @@ from sat.core.log import getLogger
log = getLogger(__name__)
from sat.tools import xml_tools
from twisted.web import client as webclient
from twisted.web import error as web_error
from twisted.internet import defer
from twisted.internet import reactor
from twisted.internet import protocol
@ -51,7 +52,8 @@ PLUGIN_INFO = {
"description": _("""This plugin help to discover our external IP address.""")
}
GET_IP_PAGE = "http://www.goffi.org/sat_tools/get_ip.php" # This page must only return external IP of the requester
# TODO: GET_IP_PAGE should be configurable in sat.conf
GET_IP_PAGE = "http://salut-a-toi.org/whereami/" # This page must only return external IP of the requester
GET_IP_LABEL = D_(u"Allow external get IP")
GET_IP_CATEGORY = "General"
GET_IP_NAME = "allow_get_ip"
@ -289,6 +291,9 @@ class IPPlugin(object):
except (internet_error.DNSLookupError, internet_error.TimeoutError):
log.warning(u"Can't access Domain Name System")
ip = None
except web_error.Error as e:
log.warning(u"Error while retrieving IP on {url}: {message}".format(url=GET_IP_PAGE, message=e))
ip = None
else:
self._external_ip_cache = ip
defer.returnValue(ip)