add docstrings
This commit is contained in:
parent
a3e7de3d6a
commit
d935979934
@ -17,10 +17,26 @@ from main.dnstools import update, SameIpError
|
|||||||
|
|
||||||
|
|
||||||
def MyIpView(request):
|
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")
|
return HttpResponse(request.META['REMOTE_ADDR'], content_type="text/plain")
|
||||||
|
|
||||||
|
|
||||||
def DetectIpView(request, secret=None):
|
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)
|
s = SessionStore(session_key=secret)
|
||||||
ipaddr = request.META['REMOTE_ADDR']
|
ipaddr = request.META['REMOTE_ADDR']
|
||||||
af = dns.inet.af_for_address(ipaddr)
|
af = dns.inet.af_for_address(ipaddr)
|
||||||
@ -100,6 +116,7 @@ def check_session_auth(user, hostname):
|
|||||||
|
|
||||||
|
|
||||||
def Response(content):
|
def Response(content):
|
||||||
|
"""shortcut for plaintext response"""
|
||||||
return HttpResponse(content, content_type='text/plain')
|
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
|
a query parameter, you can also give the hostname (then it won't use
|
||||||
the username from http basic auth as the fqdn:
|
the username from http basic auth as the fqdn:
|
||||||
https://fqdn:secret@nsupdate.info/nic/update?hostname=fqdn&myip=1.2.3.4
|
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')
|
hostname = request.GET.get('hostname')
|
||||||
auth = request.META.get('HTTP_AUTHORIZATION')
|
auth = request.META.get('HTTP_AUTHORIZATION')
|
||||||
@ -153,6 +173,9 @@ def AuthorizedNicUpdateView(request):
|
|||||||
Example URLs:
|
Example URLs:
|
||||||
|
|
||||||
https://supdate.info/nic/update?hostname=fqdn&myip=1.2.3.4
|
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')
|
hostname = request.GET.get('hostname')
|
||||||
if hostname is None:
|
if hostname is None:
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# Django settings for nsupdate project.
|
"""
|
||||||
|
Django settings for nsupdate project
|
||||||
|
"""
|
||||||
|
|
||||||
import django.conf.global_settings as DEFAULT_SETTINGS
|
import django.conf.global_settings as DEFAULT_SETTINGS
|
||||||
import dns.tsig
|
import dns.tsig
|
||||||
import os
|
import os
|
||||||
|
Loading…
x
Reference in New Issue
Block a user