Merge branch 'master' of github.com:asmaps/nsupdate.info

Conflicts:
	nsupdate/main/urls.py
This commit is contained in:
Fabian Faessler 2013-09-29 02:08:39 +02:00
commit abe8ee41ff
3 changed files with 15 additions and 8 deletions

View File

@ -24,7 +24,8 @@ def DetectIpView(request):
af = dns.inet.af_for_address(ipaddr) af = dns.inet.af_for_address(ipaddr)
key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6' key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6'
request.session[key] = ipaddr request.session[key] = ipaddr
image_data = open(settings.STATIC_ROOT+"/1px.gif", "rb").read() with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
image_data = f.read()
return HttpResponse(image_data, mimetype="image/png") return HttpResponse(image_data, mimetype="image/png")

View File

@ -21,6 +21,15 @@ class SameIpError(ValueError):
def update(fqdn, ipaddr, ttl=60): def update(fqdn, ipaddr, ttl=60):
"""
intelligent dns updater - first does a lookup on the master server to find
the current ip and only sends a dynamic update if we have a different ip.
:param fqdn: fully qualified domain name (str)
:param ipaddr: new ip address
:param ttl: time to live, default 60s (int)
:raises: SameIpError if new and old IP is the same
"""
af = dns.inet.af_for_address(ipaddr) af = dns.inet.af_for_address(ipaddr)
rdtype = 'A' if af == dns.inet.AF_INET else 'AAAA' rdtype = 'A' if af == dns.inet.AF_INET else 'AAAA'
try: try:

View File

@ -1,12 +1,9 @@
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from main.views import ( from main.views import HomeView, OverviewView, HostView, DeleteHostView
HomeView, OverviewView, HostView, DeleteHostView, from api.views import MyIpView, DetectIpView, NicUpdateView
)
from api.views import (
MyIpView, DetectIpView, NicUpdateView
)
urlpatterns = patterns('', urlpatterns = patterns(
'',
url(r'^$', HomeView.as_view(), name="home"), url(r'^$', HomeView.as_view(), name="home"),
url(r'^overview/$', OverviewView.as_view(), name='overview'), url(r'^overview/$', OverviewView.as_view(), name='overview'),
url(r'^host/(?P<pk>\d+)/$', HostView.as_view(), name='host_view'), url(r'^host/(?P<pk>\d+)/$', HostView.as_view(), name='host_view'),