Skip to content

Commit

Permalink
Merge pull request #312 from elnappo/prevent_domain
Browse files Browse the repository at this point in the history
add domain name check
  • Loading branch information
elnappo committed May 27, 2017
2 parents efbeeb2 + f3d2d03 commit 0d3b477
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
20 changes: 20 additions & 0 deletions nsupdate/main/migrations/0011_auto_20170526_2113.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import django.core.validators


class Migration(migrations.Migration):

dependencies = [
('main', '0010_auto_20151229_1717'),
]

operations = [
migrations.AlterField(
model_name='domain',
name='name',
field=models.CharField(help_text='Name of the zone where dynamic hosts may get added', unique=True, max_length=255, verbose_name='name', validators=[django.core.validators.RegexValidator(regex=b'([a-zA-Z0-9-_]+\\.)+[a-zA-Z0-9-_]{2,}', message='Invalid domain name')]),
),
]
1 change: 1 addition & 0 deletions nsupdate/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Domain(models.Model):
name = models.CharField(
_("name"),
max_length=255, # RFC 2181 (and also: max length of unique fields)
validators=[RegexValidator(regex=r"([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]{2,}", message=_("Invalid domain name"))],
unique=True,
help_text=_("Name of the zone where dynamic hosts may get added"))
nameserver_ip = models.GenericIPAddressField(
Expand Down
26 changes: 17 additions & 9 deletions nsupdate/main/templates/main/domain_add.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{% load i18n %}{% load bootstrap %}

{% block content %}
<div class="alert alert-warning" role="alert">
<i class="fa fa-exclamation-triangle"
aria-hidden="true"></i> {% trans "This feature is for advanced users only! To use this feature, you need control over at least one nameserver which is able to accept dynamic updates (RFC 2136)." %}
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
</div>
<div class="row">
<div class="col-md-6">
<div class="well well-sm">
Expand All @@ -17,19 +22,22 @@ <h3>{% trans "Add a new Domain" %}</h3>
<div class="well well-sm">
<h3>{% trans "Help" %}</h3>
<p>
{% blocktrans trimmed %}
Here you can add new domains (zones) which you control (and this is only useful if you
have some own zone which you can update automatically).
{% endblocktrans %}
{% blocktrans trimmed %}
Here you can add new domains (zones) which you control (and this is only
useful if you
have some own zone which you can update automatically).
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
You need to be able to configure the primary master nameserver of the zone so it accepts
dynamic updates (via RFC 2136 "dynamic update" protocol) if the correct update secret is presented.
{% endblocktrans %}
{% blocktrans trimmed %}
You need to be able to configure the primary master nameserver of the zone
so it accepts
dynamic updates (via RFC 2136 "dynamic update" protocol) if the correct
update secret is presented.
{% endblocktrans %}
</p>
<p>
{% trans "We'll show you configuration examples after you add a domain." %}
{% trans "We'll show you configuration examples after you add a domain." %}
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion nsupdate/main/templates/main/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h3>
<div class="col-md-12">
<h3>
{% trans "Domains (yours first, then public)" %}
<a href="{% url 'add_domain' %}" class="btn btn-primary btn-sm">{% trans "Add Domain" %}</a>
<a href="{% url 'add_domain' %}" class="btn btn-default btn-sm">{% trans "Add Domain" %}</a>
</h3>
<table class="table">
<thead>
Expand Down

0 comments on commit 0d3b477

Please sign in to comment.