Compare commits

...

6 Commits
2.1 ... master

8 changed files with 41 additions and 14 deletions

View File

@ -3,11 +3,16 @@ FROM python:3-alpine
MAINTAINER Jeffrey Forman <code@jeffreyforman.net>
WORKDIR /code
RUN apk add --no-cache nsd build-base python3-dev libffi-dev openssl-dev libc-dev libxslt-dev mariadb-connector-c-dev \
&& pip install --upgrade pip
COPY requirements.txt /code/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /code/
RUN apk add --no-cache nsd build-base python3-dev libffi-dev openssl-dev libc-dev libxslt-dev \
&& pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
EXPOSE 8000

View File

@ -36,6 +36,11 @@ docker run jforman/binder:latest
Default admin user for Binder is 'admin', and password is 'admin' as well.
If the default admin user doesn't exist in your database, create one:
```shell script
python manage.py createsuperuser
```
### MySQL database ###
If you wish to use a MySQL database, the following structure works:

View File

@ -5,6 +5,7 @@ from django.conf import settings
from jinja2 import Template
import re
import subprocess
from binder import helpers
NSD_CONF_TEMPLATE = """
# nsd.conf for {{hostname}}
@ -16,9 +17,7 @@ remote-control:
"""
ZONE_RE = re.compile("""
zone\:\s+(?P<zone_name>\S+)
\s+state: master""")
ZONE_RE = re.compile("""zone:\s+(?P<zone_name>\S+)\s+state:\s+master""")
class NSDServer(object):
"""Class to manage NSD backend server data."""
@ -53,13 +52,13 @@ class NSDServer(object):
zs_out = subprocess.check_output(
["/usr/sbin/nsd-control",
"-c", self.get_config_path(),
"-s", self.hostname,
"-s", helpers.ip_address(self.hostname),
"zonestatus"],
stderr=subprocess.STDOUT,
).decode('utf-8')
except subprocess.CalledProcessError:
raise
zones = ZONE_RE.findall(zs_out, re.MULTILINE)
zones = ZONE_RE.findall(zs_out)
zone_data = {}
zone_data['stats'] = {}
zone_data['stats']['zone_stats'] = {}

View File

@ -175,6 +175,20 @@ def ip_info(host_name):
return info
def ip_address(host_name):
"""Find an IP address for a host.
"""
try:
for s_family, s_type, s_proto, s_cannoname, s_sockaddr in socket.getaddrinfo(host_name, None):
if s_family == 2 and s_type == 1:
return s_sockaddr[0]
if s_family == 10 and s_type == 1:
return s_sockaddr[0]
except (socket.gaierror, err):
return None
return None
def send_dns_update(dns_message, dns_server, port, key_name):
"""Send DNS message to server and return response.

View File

@ -20,6 +20,8 @@ from binder.backends import nsd
from django.db import models
from django.conf import settings
from django.core.validators import MinValueValidator, MaxValueValidator
from binder import helpers
TSIG_ALGORITHMS = (('HMAC-MD5.SIG-ALG.REG.INT', 'MD5'),
('hmac-sha1', 'SHA1'),
@ -198,7 +200,7 @@ class BindServer(models.Model):
try:
xfr = dns.query.xfr(
self.hostname,
helpers.ip_address(self.hostname),
zone_name,
port=self.dns_port,
keyring=keyring,

View File

@ -1,4 +1,4 @@
{% load static from staticfiles %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
{% block header %}

View File

@ -1,4 +1,4 @@
{% load static from staticfiles %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>

View File

@ -1,6 +1,8 @@
Django
cryptography
Django
django-mysql
dnspython>=1.16.0
pybindxml>=0.7
lxml
Jinja2
lxml
pybindxml>=0.7
mysqlclient