diff --git a/nsupdate/api/views.py b/nsupdate/api/views.py index a912ca3..a2818c0 100644 --- a/nsupdate/api/views.py +++ b/nsupdate/api/views.py @@ -17,10 +17,26 @@ from main.dnstools import update, SameIpError def MyIpView(request): + """ + return the IP address (can be v4 or v6) of the client requesting this view. + + :param request: django request object + :return: HttpResponse object + """ return HttpResponse(request.META['REMOTE_ADDR'], content_type="text/plain") def DetectIpView(request, secret=None): + """ + Put the IP address (can be v4 or v6) of the client requesting this view + into the client's session. + + :param request: django request object + :return: HttpResponse object + """ + # we do not have the session as usual, as this is a different host, + # so the session cookie is not received here - thus we access it via + # the secret: s = SessionStore(session_key=secret) ipaddr = request.META['REMOTE_ADDR'] af = dns.inet.af_for_address(ipaddr) @@ -100,6 +116,7 @@ def check_session_auth(user, hostname): def Response(content): + """shortcut for plaintext response""" return HttpResponse(content, content_type='text/plain') @@ -121,6 +138,9 @@ def NicUpdateView(request): a query parameter, you can also give the hostname (then it won't use the username from http basic auth as the fqdn: https://fqdn:secret@nsupdate.info/nic/update?hostname=fqdn&myip=1.2.3.4 + + :param request: django request object + :return: HttpResponse object """ hostname = request.GET.get('hostname') auth = request.META.get('HTTP_AUTHORIZATION') @@ -153,6 +173,9 @@ def AuthorizedNicUpdateView(request): Example URLs: https://supdate.info/nic/update?hostname=fqdn&myip=1.2.3.4 + + :param request: django request object + :return: HttpResponse object """ hostname = request.GET.get('hostname') if hostname is None: diff --git a/nsupdate/nsupdate/settings.py b/nsupdate/nsupdate/settings.py index 5b70c22..ac7b30f 100644 --- a/nsupdate/nsupdate/settings.py +++ b/nsupdate/nsupdate/settings.py @@ -1,4 +1,7 @@ -# Django settings for nsupdate project. +""" +Django settings for nsupdate project +""" + import django.conf.global_settings as DEFAULT_SETTINGS import dns.tsig import os diff --git a/setup.py b/setup.py index 92add87..f84787d 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,7 @@ +""" +setup for nsupdate package +""" + from setuptools import setup, find_packages with open('README.rst') as f: