aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2013-09-23 23:28:21 +0000
committerRob Austein <sra@hactrn.net>2013-09-23 23:28:21 +0000
commit64858cf10878543fc7184acc09771d4de8de8227 (patch)
tree19510115264f32312974c93898b595b75479a5bb
parentcc4a52e681d75f44aaa9c46c518d14d06b79184d (diff)
Use netifaces library to construct a list of IP addresses to stuff
into the Django's furshlugginer ALLOWED_HOSTS list. See #628. svn path=/trunk/; revision=5517
-rw-r--r--buildtools/debian-skeleton/control2
-rw-r--r--buildtools/freebsd-skeleton/rpki-ca/Makefile1
-rw-r--r--rpkid/rpki/gui/default_settings.py17
3 files changed, 16 insertions, 4 deletions
diff --git a/buildtools/debian-skeleton/control b/buildtools/debian-skeleton/control
index 81c53bb5..81b2d8c1 100644
--- a/buildtools/debian-skeleton/control
+++ b/buildtools/debian-skeleton/control
@@ -17,7 +17,7 @@ Description: rpki.net relying party tools
Package: rpki-ca
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, rpki-rp (= ${binary:Version}), xsltproc, python (>= 2.7), python-lxml, libxml2-utils, mysql-client, mysql-server, python-mysqldb, python-vobject, python-yaml, python-django (>= 1.3.7), python-django-south (>= 0.7.5), apache2, libapache2-mod-wsgi
+Depends: ${shlibs:Depends}, ${misc:Depends}, rpki-rp (= ${binary:Version}), xsltproc, python (>= 2.7), python-lxml, libxml2-utils, mysql-client, mysql-server, python-mysqldb, python-vobject, python-yaml, python-django (>= 1.3.7), python-django-south (>= 0.7.5), apache2, libapache2-mod-wsgi, python-netifaces
Description: rpki.net certification authority tools
"Certification authority" tools for issuing RPKI certificates and
related objects using the rpki.net toolkit.
diff --git a/buildtools/freebsd-skeleton/rpki-ca/Makefile b/buildtools/freebsd-skeleton/rpki-ca/Makefile
index 350b3fb1..da9cec45 100644
--- a/buildtools/freebsd-skeleton/rpki-ca/Makefile
+++ b/buildtools/freebsd-skeleton/rpki-ca/Makefile
@@ -32,6 +32,7 @@ RPKID_DEPENDS= ${PYTHON_PKGNAMEPREFIX}lxml>0:${PORTSDIR}/devel/py-lxml
${PYTHON_PKGNAMEPREFIX}django>=1.3.7:${PORTSDIR}/www/py-django \
${PYTHON_PKGNAMEPREFIX}vobject>0:${PORTSDIR}/deskutils/py-vobject \
${PYTHON_PKGNAMEPREFIX}yaml>0:${PORTSDIR}/devel/py-yaml \
+ ${PYTHON_PKGNAMEPREFIX}netifaces>0:${PORTSDIR}/net/py-netifaces \
${PYTHON_PKGNAMEPREFIX}south>=0.7.6:${PORTSDIR}/databases/py-south
BUILD_DEPENDS+= ${RPKID_DEPENDS}
diff --git a/rpkid/rpki/gui/default_settings.py b/rpkid/rpki/gui/default_settings.py
index ecde12e2..3859247c 100644
--- a/rpkid/rpki/gui/default_settings.py
+++ b/rpkid/rpki/gui/default_settings.py
@@ -103,9 +103,20 @@ SECRET_KEY = get_secret_key()
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
# for details on why you might need this.
def get_allowed_hosts():
- allowed_hosts = rpki_config.multiget("allowed-hosts")
- allowed_hosts.append(socket.getfqdn())
- return allowed_hosts
+ allowed_hosts = set(rpki_config.multiget("allowed-hosts"))
+ allowed_hosts.add(socket.getfqdn())
+ try:
+ import netifaces
+ for interface in netifaces.interfaces():
+ addresses = netifaces.ifaddresses(interface)
+ for af in (netifaces.AF_INET, netifaces.AF_INET6):
+ if af in addresses:
+ for address in addresses[af]:
+ if "addr" in address:
+ allowed_hosts.add(address["addr"])
+ except ImportError:
+ pass
+ return list(allowed_hosts)
ALLOWED_HOSTS = get_allowed_hosts()