implement v2 API, fixes #5

This commit is contained in:
tengel 2024-03-20 09:32:36 -05:00
parent 3955f39444
commit cfad043411
4 changed files with 34 additions and 22 deletions

View file

@ -13,6 +13,13 @@ L<https://freedns.afraid.org>; the software goals are for simplicity,
flexibility and configurability while using the minimal system tools
installed with most distributions.
Version 1.x = FreeDNS API v1
Version 2.x = FreeDNS API v2
If upgrading from API v1 to v2, a manual action is required on the
FreeDNS website to generate a new API key for each domain name. See
L<https://freedns.afraid.org/dynamic/v2/> for more information.
=head1 OPTIONS
=over 4

View file

@ -2,7 +2,7 @@
#
## petrified - bash client to update dynamic DNS at freedns.afraid.org
## Copyright (c) 2015 Troy Engel
## Version: 1.0.6
## Version: 2.0.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -37,8 +37,8 @@ while getopts ":c:" opt; do
esac
done
## How to update DNS - DDNS_KEY is unique per domain
DDNS_URL=https://freedns.afraid.org/dynamic/update.php
## v2 API - How to update DNS - DDNS_KEY is unique per domain
DDNS_URL=https://sync.afraid.org/u/
DDNS_KEY=""
## Which URL to use to get an IP
@ -215,7 +215,7 @@ fi
# If they don't match, tell upstream
if [[ "${OLDIP}" != "${NEWIP}" ]]; then
UPDURL="${DDNS_URL}?${DDNS_KEY}&address=${NEWIP}"
UPDURL="${DDNS_URL}${DDNS_KEY}/?ip=${NEWIP}"
RESULT=$(curl -m ${CURL_WAIT} -sk "${UPDURL}" 2>/dev/null)
logmsg "${RESULT}"
else

View file

@ -1,4 +1,4 @@
.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
@ -46,7 +46,7 @@
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
@ -54,20 +54,16 @@
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
.if !\nF .nr F 0
.if \nF>0 \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
@ -133,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "PETRIFIED 1"
.TH PETRIFIED 1 "2016-01-24" "petrified 1.0.6" "Petrified Manual"
.TH PETRIFIED 1 "2017-09-16" "petrified 2.0.0" "Petrified Manual"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@ -149,6 +145,15 @@ Usage: \fBpetrified\fR [ \fB\-c\fR \fIconfig\fR ]
<https://freedns.afraid.org>; the software goals are for simplicity,
flexibility and configurability while using the minimal system tools
installed with most distributions.
.PP
.Vb 2
\& Version 1.x = FreeDNS API v1
\& Version 2.x = FreeDNS API v2
.Ve
.PP
If upgrading from \s-1API\s0 v1 to v2, a manual action is required on the
FreeDNS website to generate a new \s-1API\s0 key for each domain name. See
<https://freedns.afraid.org/dynamic/v2/> for more information.
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-c\fR \fIconfig\fR" 4

View file

@ -14,11 +14,11 @@
# This is the unique string for the dynamic DNS entry to update; visit
# http://freedns.afraid.org/dynamic/ - next to the DNS entries towards
# the bottom is a link "Direct URL"; copy that and extract the string
# after the '...update.php?' part and put here.
# https://freedns.afraid.org/dynamic/v2/ - next to the DNS entries towards
# the bottom is a link to sync.afraid.org; copy that and extract the string
# after the '.../u/' part and put here.
#
# Example: DDNS_KEY=9C4yjq3kaekkYNbYsKRqcosTmouMYbfVMLkJtR==
# Example: DDNS_KEY=ZIfSWnXKuDqMpNEsTXBA852
DDNS_KEY=
# Which URL to use to get an IP - the expectation is output from this