diff --git a/management/daemon.py b/management/daemon.py index a3ee79a3..f23c2af1 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -184,12 +184,11 @@ def dns_set_record(qname, rtype="A", value=None): # Get the value from the URL, then the POST parameters, or if it is not set then # use the remote IP address of the request --- makes dynamic DNS easy. To clear a # value, '' must be explicitly passed. - print(request.environ) if value is None: value = request.form.get("value") if value is None: value = request.environ.get("HTTP_X_FORWARDED_FOR") # normally REMOTE_ADDR but we're behind nginx as a reverse proxy - if value == '': + if value == '' or value == '__delete__': # request deletion value = None if set_custom_dns_record(qname, rtype, value, env): diff --git a/management/templates/system-dns.html b/management/templates/system-dns.html index a35e36d8..bc8e554d 100644 --- a/management/templates/system-dns.html +++ b/management/templates/system-dns.html @@ -37,17 +37,19 @@

Send a POST request like this:

-
curl -d "" --user {email}:{password} https://{{hostname}}/admin/dns/set/{qname}[/{rtype}[/{value}]]
+
curl -d "" --user {email}:{password} https://{{hostname}}/admin/dns/set/qname[/rtype[/value]]
- - + +
Parameter Value
email The email address of any administrative user here.
password That user’s password.
qname The fully qualified domain name for the record you are trying to set.
rtype Optional. The resource type: A (an IPv4 address; the default), AAAA (an IPv6 address), TXT (a text string), or CNAME (an alias, which is a fully qualified domain name).
value Optional-ish. The new record’s value. If not provided, the IPv4 address of the remote host is used — this is handy for dynamic DNS! You can also set this in a POST parameter. To delete a record, pass “value=” in the POST body.
rtype The resource type. A if omitted. Possible values: A (an IPv4 address), AAAA (an IPv6 address), TXT (a text string), or CNAME (an alias, which is a fully qualified domain name).
value The new record’s value. If omitted, the IPv4 address of the remote host is used. This is handy for dynamic DNS! To delete a record, use “__delete__”.
+

Note that -d "" is merely to ensure curl sends a POST request. You do not need to put anything inside the quotes. You can also pass the value using typical form encoding in the POST body.

+

Examples:

# sets laptop.mydomain.com to point to the IP address of the machine you are executing curl on
@@ -56,11 +58,12 @@ curl -d "" --user me@mydomain.com:###### https://{{hostname}}/admin/dns/set/lapt
 # sets an alias
 curl -d "" --user me@mydomain.com:###### https://{{hostname}}/admin/dns/set/foo.mydomain.com/cname/bar.mydomain.com
 
-# sets a TXT record
-curl -d "value=something%20here" --user me@mydomain.com:###### https://{{hostname}}/admin/dns/set/foo.mydomain.com/txt
+# clears the alias
+curl -d "" --user me@mydomain.com:###### https://{{hostname}}/admin/dns/set/bar.mydomain.com/cname/__delete__
 
-# clears the TXT record
-curl -d "value=" --user me@mydomain.com:###### https://{{hostname}}/admin/dns/set/foo.mydomain.com/txt
+# sets a TXT record using the alternate value syntax +curl -d "value=something%20here" --user me@mydomain.com:###### https://{{hostname}}/admin/dns/set/foo.mydomain.com/txt +

External DNS