implement v2 API, fixes #5

This commit is contained in:
troyengel 2017-09-16 10:22:07 -05:00
parent 414218468f
commit e35aa941e1
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 flexibility and configurability while using the minimal system tools
installed with most distributions. 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 =head1 OPTIONS
=over 4 =over 4

View file

@ -2,7 +2,7 @@
# #
## petrified - bash client to update dynamic DNS at freedns.afraid.org ## petrified - bash client to update dynamic DNS at freedns.afraid.org
## Copyright (c) 2015 Troy Engel ## 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 # 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 # it under the terms of the GNU General Public License as published by
@ -37,8 +37,8 @@ while getopts ":c:" opt; do
esac esac
done done
## How to update DNS - DDNS_KEY is unique per domain ## v2 API - How to update DNS - DDNS_KEY is unique per domain
DDNS_URL=https://freedns.afraid.org/dynamic/update.php DDNS_URL=https://sync.afraid.org/u/
DDNS_KEY="" DDNS_KEY=""
## Which URL to use to get an IP ## Which URL to use to get an IP
@ -215,7 +215,7 @@ fi
# If they don't match, tell upstream # If they don't match, tell upstream
if [[ "${OLDIP}" != "${NEWIP}" ]]; then 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) RESULT=$(curl -m ${CURL_WAIT} -sk "${UPDURL}" 2>/dev/null)
logmsg "${RESULT}" logmsg "${RESULT}"
else 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: .\" Standard preamble:
.\" ======================================================================== .\" ========================================================================
@ -46,7 +46,7 @@
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds 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 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the .\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion. .\" output yourself in some meaningful fashion.
@ -54,20 +54,16 @@
.\" Avoid warning from groff about undefined register 'F'. .\" Avoid warning from groff about undefined register 'F'.
.de IX .de IX
.. ..
.nr rF 0 .if !\nF .nr F 0
.if \n(.g .if rF .nr rF 1 .if \nF>0 \{\
.if (\n(rF:(\n(.g==0)) \{ . de IX
. if \nF \{ . tm Index:\\$1\t\\n%\t"\\$2"
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
.. ..
. if !\nF==2 \{ . if !\nF==2 \{\
. nr % 0 . nr % 0
. nr F 2 . nr F 2
. \}
. \} . \}
.\} .\}
.rr rF
.\" .\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts. .\" Fear. Run. Save yourself. No user-serviceable parts.
@ -133,7 +129,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "PETRIFIED 1" .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 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .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, <https://freedns.afraid.org>; the software goals are for simplicity,
flexibility and configurability while using the minimal system tools flexibility and configurability while using the minimal system tools
installed with most distributions. 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" .SH "OPTIONS"
.IX Header "OPTIONS" .IX Header "OPTIONS"
.IP "\fB\-c\fR \fIconfig\fR" 4 .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 # This is the unique string for the dynamic DNS entry to update; visit
# http://freedns.afraid.org/dynamic/ - next to the DNS entries towards # https://freedns.afraid.org/dynamic/v2/ - next to the DNS entries towards
# the bottom is a link "Direct URL"; copy that and extract the string # the bottom is a link to sync.afraid.org; copy that and extract the string
# after the '...update.php?' part and put here. # after the '.../u/' part and put here.
# #
# Example: DDNS_KEY=9C4yjq3kaekkYNbYsKRqcosTmouMYbfVMLkJtR== # Example: DDNS_KEY=ZIfSWnXKuDqMpNEsTXBA852
DDNS_KEY= DDNS_KEY=
# Which URL to use to get an IP - the expectation is output from this # Which URL to use to get an IP - the expectation is output from this