PKG_NAME:=ddns-scripts
# Version == major.minor.patch
# increase on new functionality (minor) or patches (patch)
-PKG_VERSION:=2.6.1
+PKG_VERSION:=2.6.2
# Release == build
# increase on changes of services files or tld_names.dat
PKG_RELEASE:=1
- Proxy server support
- log file support
- support to run once
- .
Version: $(PKG_VERSION)-$(PKG_RELEASE)
Info : http://wiki.openwrt.org/doc/howto/ddns.client
- .
$(PKG_MAINTAINER)
endef
##### **********************************
define Package/$(PKG_NAME)_cloudflare
$(call Package/$(PKG_NAME)/Default)
- TITLE:=DDNS extension for CloudFlare
+ TITLE:=DDNS extension for CloudFlare.com
DEPENDS:=$(PKG_NAME)
endef
define Package/$(PKG_NAME)_cloudflare/description
- Dynamic DNS Client scripts extension for CloudFlare
+ Dynamic DNS Client scripts extension for CloudFlare.com
endef
##### **********************************
##### **********************************
define Package/$(PKG_NAME)_cloudflare/install
$(INSTALL_DIR) $(1)/usr/lib/ddns
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_CloudFlare.sh $(1)/usr/lib/ddns
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_cloudflare_com.sh $(1)/usr/lib/ddns
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/tld_names.dat.gz $(1)/usr/lib/ddns
endef
define Package/$(PKG_NAME)_cloudflare/postinst
#!/bin/sh
- echo -e '"CloudFlare"\t"update_CloudFlare.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
- echo -e '"CloudFlare"\t"update_CloudFlare.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
+ echo -e '"cloudflare.com"\t"update_cloudflare_com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
+ echo -e '"cloudflare.com"\t"update_cloudflare_com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
+ /bin/sed -i '/service_name/s/CloudFlare/cloudflare\.com/g' $${IPKG_INSTROOT}/etc/config/ddns
endef
define Package/$(PKG_NAME)_cloudflare/prerm
#!/bin/sh
- /bin/sed -i '/update_CloudFlare\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
- /bin/sed -i '/update_CloudFlare\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
+ /bin/sed -i '/update_cloudflare_com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
+ /bin/sed -i '/update_cloudflare_com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
endef
##### **********************************
define Package/$(PKG_NAME)_no-ip_com/install
$(INSTALL_DIR) $(1)/usr/lib/ddns
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_No-IP.com.sh $(1)/usr/lib/ddns
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_no-ip_com.sh $(1)/usr/lib/ddns
endef
define Package/$(PKG_NAME)_no-ip_com/postinst
#!/bin/sh
- echo -e '"No-IP.com"\t"update_No-IP.com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
- echo -e '"NoIP.com"\t"update_No-IP.com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
+ echo -e '"no-ip.com"\t"update_no-ip_com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
+ /bin/sed -i '/service_name/s/NoIP\.com/no-ip\.com/g' $${IPKG_INSTROOT}/etc/config/ddns
+ /bin/sed -i '/service_name/s/No-IP\.com/no-ip\.com/g' $${IPKG_INSTROOT}/etc/config/ddns
endef
define Package/$(PKG_NAME)_no-ip_com/prerm
#!/bin/sh
- /bin/sed -i '/update_No-IP\.com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
+ /bin/sed -i '/update_no-ip_com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
endef
##### **********************************
endef
define Package/$(PKG_NAME)_nsupdate/postinst
#!/bin/sh
- echo -e '"Bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
- echo -e '"Bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
+ echo -e '"bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
+ echo -e '"bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
+ /bin/sed -i '/service_name/s/Bind-nsupdate/bind-nsupdate/g' $${IPKG_INSTROOT}/etc/config/ddns
endef
define Package/$(PKG_NAME)_nsupdate/prerm
#!/bin/sh
# Variomedia AG
"variomedia.de" "http://[USERNAME]:[PASSWORD]@dyndns.variomedia.de/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg"
- #DtDNS
+# DtDNS
"dtdns.com" "http://www.dtdns.com/api/autodns.cfm?id=[DOMAIN]&pw=[PASSWORD]&ip=[IP]"
# dy.fi Dynamic DNS for finnish users (IP autodetected by provider)
tv.bo
// br : http://registro.br/dominio/categoria.html
br
adm.br
adv.br
org.bt
// bv : No registrations at this time.
bv
// bw : http://en.wikipedia.org/wiki/.bw
net.cm
// cn : http://en.wikipedia.org/wiki/.cn
cn
ac.cn
com.cn
tw.cn
// co : http://en.wikipedia.org/wiki/.co
co
arts.co
com.co
art.dz
// ec : http://www.nic.ec/reg/paso1.asp
ec
com.ec
info.ec
ga
// gb : This registry is effectively dormant
gb
// gd : http://en.wikipedia.org/wiki/.gd
gm
// gn : http://psg.com/dns/gn/gn.txt
gn
ac.gn
com.gn
gq
// gr : https://grweb.ics.forth.gr/english/1617-B-2005.html
gr
com.gr
edu.gr
org.gy
// hk : https://www.hkdnr.hk
hk
com.hk
edu.hk
org.il
// im : https://www.nic.im/
im
ac.im
co.im
// jp : http://en.wikipedia.org/wiki/.jp
// http://jprs.co.jp/en/jpdomain.html
jp
// jp organizational type names
ac.jp
com.kz
// la : http://en.wikipedia.org/wiki/.la
la
int.la
net.la
org.la
// lb : http://en.wikipedia.org/wiki/.lb
lb
com.lb
edu.lb
ac.lk
// lr : http://psg.com/dns/lr/lr.txt
lr
com.lr
edu.lr
org.ms
// mt : https://www.nic.org.mt/go/policy
mt
com.mt
edu.mt
org.mw
// mx : http://www.nic.mx/
mx
com.mx
org.mx
other.nf
store.nf
-// ng : http://psg.com/dns/ng/
+// ng : http://www.nira.org.ng/index.php/join-us/register-ng-domain/189-nira-slds
ng
com.ng
edu.ng
+gov.ng
+i.ng
+mil.ng
+mobi.ng
name.ng
net.ng
org.ng
sch.ng
-gov.ng
-mil.ng
-mobi.ng
// ni : http://www.nic.ni/
com.ni
*.np
// nr : http://cenpac.net.nr/dns/index.html
nr
biz.nr
info.nr
nu
// nz : http://en.wikipedia.org/wiki/.nz
nz
ac.nz
co.nz
*.pg
// ph : http://www.domains.ph/FAQ2.asp
ph
com.ph
net.ph
info.pk
// pl http://www.dns.pl/english/index.html
-// updated by .PL registry on 2015-04-28
+// Submitted by registry
pl
com.pl
net.pl
prof.pr
ac.pr
-// pro : http://www.nic.pro/support_faq.htm
+// pro : http://registry.pro/get-pro
pro
+aaa.pro
aca.pro
+acct.pro
+avocat.pro
bar.pro
cpa.pro
+eng.pro
jur.pro
law.pro
med.pro
-eng.pro
+recht.pro
// ps : http://en.wikipedia.org/wiki/.ps
// http://www.nic.ps/registration/policy.html#reg
belau.pw
// py : http://www.nic.py/pautas.html#seccion_9
-// Confirmed by registry 2012-10-03
+// Submitted by registry
py
com.py
coop.py
// re : http://www.afnic.re/obtenir/chartes/nommage-re/annexe-descriptifs
re
-com.re
asso.re
+com.re
nom.re
// ro : http://www.rotld.ro/
ro
+arts.ro
com.ro
-org.ro
-tm.ro
-nt.ro
-nom.ro
+firm.ro
info.ro
+nom.ro
+nt.ro
+org.ro
rec.ro
-arts.ro
-firm.ro
store.ro
+tm.ro
www.ro
-// rs : http://en.wikipedia.org/wiki/.rs
+// rs : https://www.rnids.rs/en/domains/national-domains
rs
+ac.rs
co.rs
-org.rs
edu.rs
-ac.rs
gov.rs
in.rs
+org.rs
// ru : http://www.cctld.ru/ru/docs/aktiv_8.php
// Industry domains
sch.sa
// sb : http://www.sbnic.net.sb/
sb
com.sb
edu.sb
edu.sc
// sd : http://www.isoc.sd/sudanic.isoc.sd/billing_pricing.htm
sd
com.sd
net.sd
info.sd
// se : http://en.wikipedia.org/wiki/.se
se
a.se
ac.se
si
// sj : No registrations at this time.
sj
// sk : http://en.wikipedia.org/wiki/.sk
sk
// sl : http://www.nic.sl
sl
com.sl
net.sl
red.sv
// sx : http://en.wikipedia.org/wiki/.sx
sx
gov.sx
tg
// th : http://en.wikipedia.org/wiki/.th
th
ac.th
co.th
turen.tn
// to : http://en.wikipedia.org/wiki/.to
to
com.to
gov.to
// subTLDs: https://www.nic.tr/forms/eng/policies.pdf
// and: https://www.nic.tr/forms/politikalar.pdf
tr
com.tr
info.tr
xn--czrw28b.tw
// tz : http://www.tznic.or.tz/index.php/domains
tz
ac.tz
co.tz
tv.tz
// ua : https://hostmaster.ua/policy/?ua
ua
// ua 2LD
com.ua
va
// vc : http://en.wikipedia.org/wiki/.vc
vc
com.vc
net.vc
edu.vc
// ve : https://registro.nic.ve/
-// Confirmed by registry 2012-10-04
-// Updated 2014-05-20 - Bug 940478
+// Submitted by registry
ve
arts.ve
co.ve
xn--ygbi2ammx
// xn--90a3ac ("srb", Cyrillic) : RS
-// http://www.rnids.rs/en/the-.срб-domain
+// https://www.rnids.rs/en/domains/national-domains
срб
xn--90a3ac
пр.срб
// (Note: these are in alphabetical order by company name)
// Amazon CloudFront : https://aws.amazon.com/cloudfront/
cloudfront.net
// Amazon Elastic Compute Cloud: https://aws.amazon.com/ec2/
ap-northeast-1.compute.amazonaws.com
+ap-northeast-2.compute.amazonaws.com
ap-southeast-1.compute.amazonaws.com
ap-southeast-2.compute.amazonaws.com
cn-north-1.compute.amazonaws.cn
+compute-1.amazonaws.com
compute.amazonaws.cn
compute.amazonaws.com
-compute-1.amazonaws.com
-eu-west-1.compute.amazonaws.com
eu-central-1.compute.amazonaws.com
+eu-west-1.compute.amazonaws.com
sa-east-1.compute.amazonaws.com
us-east-1.amazonaws.com
us-gov-west-1.compute.amazonaws.com
z-2.compute-1.amazonaws.com
// Amazon Elastic Beanstalk : https://aws.amazon.com/elasticbeanstalk/
elasticbeanstalk.com
// Amazon Elastic Load Balancing : https://aws.amazon.com/elasticloadbalancing/
elb.amazonaws.com
// Amazon S3 : https://aws.amazon.com/s3/
s3.amazonaws.com
s3-ap-northeast-1.amazonaws.com
+s3-ap-northeast-2.amazonaws.com
s3-ap-southeast-1.amazonaws.com
s3-ap-southeast-2.amazonaws.com
+s3-eu-central-1.amazonaws.com
+s3-eu-west-1.amazonaws.com
s3-external-1.amazonaws.com
s3-external-2.amazonaws.com
s3-fips-us-gov-west-1.amazonaws.com
-s3-eu-central-1.amazonaws.com
-s3-eu-west-1.amazonaws.com
s3-sa-east-1.amazonaws.com
s3-us-gov-west-1.amazonaws.com
s3-us-west-1.amazonaws.com
s3-us-west-2.amazonaws.com
+s3.ap-northeast-2.amazonaws.com
s3.cn-north-1.amazonaws.com.cn
s3.eu-central-1.amazonaws.com
// BetaInABox
betainabox.com
// CentralNic : http://www.centralnic.com/names/domains
ae.org
ar.com
br.com
za.com
// Africa.com Web Solutions Ltd : https://registry.africa.com
africa.com
+// Citrix : https://citrix.com
+xenapponazure.com
+
// iDOT Services Limited : http://www.domain.gr.com
gr.com
// Radix FZC : http://domains.in.net
in.net
// US REGISTRY LLC : http://us.org
us.org
// co.com Registry, LLC : https://registry.co.com
co.com
// c.la : http://www.c.la/
c.la
// cloudControl : https://www.cloudcontrol.com/
cloudcontrolled.com
cloudcontrolapp.com
// co.ca : http://registry.co.ca/
co.ca
+// i-registry s.r.o. : http://www.i-registry.cz/
+co.cz
+
// CDN77.com : http://www.cdn77.com
c.cdn77.org
cdn77-ssl.net
r.cdn77.net
co.no
// Commerce Guys, SAS
*.platform.sh
// Cupcake : https://cupcake.io/
cupcake.is
// DreamHost : http://www.dreamhost.com/
dreamhosters.com
// Drobo : http://www.drobo.com/
mydrobo.com
// DuckDNS : http://www.duckdns.org/
duckdns.org
// DynDNS.com : http://www.dyndns.com/services/dns/dyndns/
writesthisblog.com
// EU.org https://eu.org/
-
eu.org
al.eu.org
asso.eu.org
us.eu.org
// Fastly Inc. http://www.fastly.com/
a.ssl.fastly.net
b.ssl.fastly.net
global.ssl.fastly.net
global.prod.fastly.net
// Firebase, Inc.
firebaseapp.com
// Flynn : https://flynn.io
flynnhub.com
// GDS : https://www.gov.uk/service-manual/operations/operating-servicegovuk-subdomains
service.gov.uk
// GitHub, Inc.
github.io
githubusercontent.com
// GlobeHosting, Inc.
ro.com
// Google, Inc.
appspot.com
blogspot.ae
blogspot.al
hashbang.sh
// Heroku : https://www.heroku.com/
herokuapp.com
herokussl.com
// iki.fi
iki.fi
// info.at : http://www.info.at/
co.pl
// Microsoft : http://microsoft.com
azurewebsites.net
azure-mobile.net
cloudapp.net
// Mozilla Foundation : https://mozilla.org/
bmoattachments.org
// Neustar Inc.
4u.com
// ngrok : https://ngrok.com/
ngrok.io
// NFSN, Inc. : https://www.NearlyFreeSpeech.NET/
nfshost.com
// NYC.mn : http://www.information.nyc.mn
nyc.mn
// One Fold Media : http://www.onefoldmedia.com/
nid.io
// Opera Software, A.S.A.
operaunite.com
// OutSystems
outsystemscloud.com
// Pagefront : https://www.pagefronthq.com/
pagefrontapp.com
// .pl domains (grandfathered)
zakopane.pl
// Pantheon Systems, Inc. : https://pantheon.io/
pantheon.io
gotpantheon.com
+// prgmr.com : https://prgmr.com/
+xen.prgmr.com
+
// priv.at : http://www.nic.priv.at/
priv.at
// QA2
-// Submitted by Daniel Dent (https://www.danieldent.com/) 2015-07-16
+// Submitted by Daniel Dent (https://www.danieldent.com/)
qa2.com
// Rackmaze LLC : https://www.rackmaze.com
rackmaze.com
rackmaze.net
// Red Hat, Inc. OpenShift : https://openshift.redhat.com/
rhcloud.com
// Sandstorm Development Group, Inc. : https://sandcats.io/
sandcats.io
// Service Online LLC : http://drs.ua/
biz.ua
co.ua
pp.ua
// SinaAppEngine : http://sae.sina.com.cn/
sinaapp.com
vipsinaapp.com
1kapp.com
// Synology, Inc. : https://www.synology.com/
diskstation.me
dscloud.biz
dscloud.me
sopot.pl
// UDR Limited : http://www.udr.hk.com
hk.com
hk.org
ltd.hk
inc.hk
// Yola : https://www.yola.com/
yolasite.com
// ZaNiC : http://www.za.net/
za.net
za.org
+++ /dev/null
-#
-#.Distributed under the terms of the GNU General Public License (GPL) version 2.0
-#
-# script for sending updates to cloudflare.com
-#.2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
-# many thanks to Paul for testing and feedback during development
-#
-# This script is parsed by dynamic_dns_functions.sh inside send_update() function
-#
-# using following options from /etc/config/ddns
-# option username - your cloudflare e-mail
-# option password - cloudflare api key, you can get it from cloudflare.com/my-account/
-# option domain - your full hostname to update, in cloudflare its subdomain.domain
-# i.e. myhost.example.com where myhost is the subdomain and example.com is your domain
-#
-# variable __IP already defined with the ip-address to use for update
-#
-[ $use_https -eq 0 ] && write_log 14 "Cloudflare only support updates via Secure HTTP (HTTPS). Please correct configuration!"
-[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
-[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
-
-local __RECID __URL __KEY __KEYS __FOUND __SUBDOM __DOMAIN __TLD
-
-# split given Host/Domain into TLD, registrable domain, and subdomain
-split_FQDN $domain __TLD __DOMAIN __SUBDOM
-[ $? -ne 0 -o -z "$__DOMAIN" ] && \
- write_log 14 "Wrong Host/Domain configuration ($domain). Please correct configuration!"
-
-# put together what we need
-__DOMAIN="$__DOMAIN.$__TLD"
-
-# parse OpenWrt script with
-# functions for parsing and generating json
-. /usr/share/libubox/jshn.sh
-
-# function copied from /usr/share/libubox/jshn.sh
-# from BB14.09 for backward compatibility to AA12.09
-grep -i "json_get_keys" /usr/share/libubox/jshn.sh >/dev/null 2>&1 || json_get_keys() {
- local __dest="$1"
- local _tbl_cur
-
- if [ -n "$2" ]; then
- json_get_var _tbl_cur "$2"
- else
- _json_get_var _tbl_cur JSON_CUR
- fi
- local __var="${JSON_PREFIX}KEYS_${_tbl_cur}"
- eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
-}
-
-# function to "sed" unwanted string parts from DATFILE
-cleanup() {
- # based on the sample output on cloudflare.com homepage we need to do some cleanup
- sed -i 's/^[ \t]*//;s/[ \t]*$//' $DATFILE # remove invisible chars at beginning and end of lines
- sed -i '/^-$/d' $DATFILE # remove lines with "-" (dash)
- sed -i '/^$/d' $DATFILE # remove empty lines
- sed -i "#'##g" $DATFILE # remove "'" (single quote)
-}
-
-[ -n "$rec_id" ] && __RECID="$rec_id" || {
- # build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
- # to "rec_load_all" to detect rec_id needed for update
- __URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
- __URL="${__URL}?a=rec_load_all" # -d 'a=rec_load_all'
- __URL="${__URL}&tkn=$password" # -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25'
- __URL="${__URL}&z=$__DOMAIN" # -d 'z=example.com'
-
- # lets request the data
- do_transfer "$__URL" || return 1
-
- cleanup # cleanup dat file
- json_load "$(cat $DATFILE)" # lets extract data
- __FOUND=0 # found record indicator
- json_get_var __RES "result" # cloudflare result of last request
- json_get_var __MSG "msg" # cloudflare error message
- [ "$__RES" != "success" ] && {
- write_log 4 "'rec_load_all' failed with error: \n$__MSG"
- return 1
- }
-
- json_select "response"
- json_select "recs"
- json_select "objs"
- json_get_keys __KEYS
- for __KEY in $__KEYS; do
- local __ZONE __DISPLAY __NAME __TYPE
- json_select "$__KEY"
- # json_get_var __ZONE "zone_name" # for debugging
- # json_get_var __DISPLAY "display_name" # for debugging
- json_get_var __NAME "name"
- json_get_var __TYPE "type"
- if [ "$__NAME" = "$domain" ]; then
- # we must verify IPv4 and IPv6 because there might be both for the same host
- [ \( $use_ipv6 -eq 0 -a "$__TYPE" = "A" \) -o \( $use_ipv6 -eq 1 -a "$__TYPE" = "AAAA" \) ] && {
- __FOUND=1 # mark found
- break # found leave for loop
- }
- fi
- json_select ..
- done
- [ $__FOUND -eq 0 ] && {
- # we don't need to continue trying to update cloudflare because record to update does not exist
- # user has to setup record first outside ddns-scripts
- write_log 14 "No valid record found at Cloudflare setup. Please create first!"
- }
- json_get_var __RECID "rec_id" # last thing to do get rec_id
- json_cleanup # cleanup
- write_log 7 "rec_id '$__RECID' detected for host/domain '$domain'"
-}
-
-# build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
-# for "rec_edit" to update IP address
-__URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
-__URL="${__URL}?a=rec_edit" # -d 'a=rec_edit'
-__URL="${__URL}&tkn=$password" # -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25'
-__URL="${__URL}&id=$__RECID" # -d 'id=9001'
-__URL="${__URL}&z=$__DOMAIN" # -d 'z=example.com'
-
-[ $use_ipv6 -eq 0 ] && __URL="${__URL}&type=A" # -d 'type=A' (IPv4)
-[ $use_ipv6 -eq 1 ] && __URL="${__URL}&type=AAAA" # -d 'type=AAAA' (IPv6)
-
-# handle subdomain or domain record
-[ -n "$__SUBDOM" ] && __URL="${__URL}&name=$__SUBDOM" # -d 'name=sub' (HOST/SUBDOMAIN)
-[ -z "$__SUBDOM" ] && __URL="${__URL}&name=$__DOMAIN" # -d 'name=example.com'(DOMAIN)
-
-__URL="${__URL}&content=$__IP" # -d 'content=1.2.3.4'
-__URL="${__URL}&service_mode=0" # -d 'service_mode=0'
-__URL="${__URL}&ttl=1" # -d 'ttl=1'
-
-# lets do the update
-do_transfer "$__URL" || return 1
-
-cleanup # cleanup tmp file
-json_load "$(cat $DATFILE)" # lets extract data
-json_get_var __RES "result" # cloudflare result of last request
-json_get_var __MSG "msg" # cloudflare error message
-[ "$__RES" != "success" ] && {
- write_log 4 "'rec_edit' failed with error:\n$__MSG"
- return 1
-}
-write_log 7 "Update of rec_id '$__RECID' successful"
-return 0
+++ /dev/null
-#
-#.Distributed under the terms of the GNU General Public License (GPL) version 2.0
-#
-# script for sending updates to no-ip.com / noip.com
-#.2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
-#
-# This script is parsed by dynamic_dns_functions.sh inside send_update() function
-#
-# provider did not reactivate records, if no IP change was recognized
-# so we send a dummy (localhost) and a seconds later we send the correct IP addr
-#
-local __DUMMY
-local __UPDURL="http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
-# inside url we need username and password
-[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
-[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
-
-# set IP version dependend dummy (localhost)
-[ $use_ipv6 -eq 0 ] && __DUMMY="127.0.0.1" || __DUMMY="::1"
-
-# lets do DUMMY transfer
-write_log 7 "sending dummy IP to 'no-ip.com'"
-__URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
- -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__DUMMY#g")
-[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
-
-do_transfer "$__URL" || return 1
-
-write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
-# analyse provider answers
-# "good [IP_ADR]" = successful
-# "nochg [IP_ADR]" = no change but OK
-grep -E "good|nochg" $DATFILE >/dev/null 2>&1 || return 1
-
-# lets wait a seconds
-sleep 1
-
-# now send the correct data
-write_log 7 "sending real IP to 'no-ip.com'"
-__URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
- -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
-[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
-
-do_transfer "$__URL" || return 1
-
-write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
-# analyse provider answers
-# "good [IP_ADR]" = successful
-# "nochg [IP_ADR]" = no change but OK
-grep -E "good|nochg" $DATFILE >/dev/null 2>&1
-return $? # "0" if "good" or "nochg" found
-
--- /dev/null
+#
+#.Distributed under the terms of the GNU General Public License (GPL) version 2.0
+#
+# script for sending updates to cloudflare.com
+#.2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
+# many thanks to Paul for testing and feedback during development
+#
+# This script is parsed by dynamic_dns_functions.sh inside send_update() function
+#
+# using following options from /etc/config/ddns
+# option username - your cloudflare e-mail
+# option password - cloudflare api key, you can get it from cloudflare.com/my-account/
+# option domain - your full hostname to update, in cloudflare its subdomain.domain
+# i.e. myhost.example.com where myhost is the subdomain and example.com is your domain
+#
+# variable __IP already defined with the ip-address to use for update
+#
+[ $use_https -eq 0 ] && write_log 14 "Cloudflare only support updates via Secure HTTP (HTTPS). Please correct configuration!"
+[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
+[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
+
+local __RECID __URL __KEY __KEYS __FOUND __SUBDOM __DOMAIN __TLD
+
+# split given Host/Domain into TLD, registrable domain, and subdomain
+split_FQDN $domain __TLD __DOMAIN __SUBDOM
+[ $? -ne 0 -o -z "$__DOMAIN" ] && \
+ write_log 14 "Wrong Host/Domain configuration ($domain). Please correct configuration!"
+
+# put together what we need
+__DOMAIN="$__DOMAIN.$__TLD"
+
+# parse OpenWrt script with
+# functions for parsing and generating json
+. /usr/share/libubox/jshn.sh
+
+# function copied from /usr/share/libubox/jshn.sh
+# from BB14.09 for backward compatibility to AA12.09
+grep -i "json_get_keys" /usr/share/libubox/jshn.sh >/dev/null 2>&1 || json_get_keys() {
+ local __dest="$1"
+ local _tbl_cur
+
+ if [ -n "$2" ]; then
+ json_get_var _tbl_cur "$2"
+ else
+ _json_get_var _tbl_cur JSON_CUR
+ fi
+ local __var="${JSON_PREFIX}KEYS_${_tbl_cur}"
+ eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
+}
+
+# function to "sed" unwanted string parts from DATFILE
+cleanup() {
+ # based on the sample output on cloudflare.com homepage we need to do some cleanup
+ sed -i 's/^[ \t]*//;s/[ \t]*$//' $DATFILE # remove invisible chars at beginning and end of lines
+ sed -i '/^-$/d' $DATFILE # remove lines with "-" (dash)
+ sed -i '/^$/d' $DATFILE # remove empty lines
+ sed -i "#'##g" $DATFILE # remove "'" (single quote)
+}
+
+[ -n "$rec_id" ] && __RECID="$rec_id" || {
+ # build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
+ # to "rec_load_all" to detect rec_id needed for update
+ __URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
+ __URL="${__URL}?a=rec_load_all" # -d 'a=rec_load_all'
+ __URL="${__URL}&tkn=$password" # -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25'
+ __URL="${__URL}&z=$__DOMAIN" # -d 'z=example.com'
+
+ # lets request the data
+ do_transfer "$__URL" || return 1
+
+ cleanup # cleanup dat file
+ json_load "$(cat $DATFILE)" # lets extract data
+ __FOUND=0 # found record indicator
+ json_get_var __RES "result" # cloudflare result of last request
+ json_get_var __MSG "msg" # cloudflare error message
+ [ "$__RES" != "success" ] && {
+ write_log 4 "'rec_load_all' failed with error: \n$__MSG"
+ return 1
+ }
+
+ json_select "response"
+ json_select "recs"
+ json_select "objs"
+ json_get_keys __KEYS
+ for __KEY in $__KEYS; do
+ local __ZONE __DISPLAY __NAME __TYPE
+ json_select "$__KEY"
+ # json_get_var __ZONE "zone_name" # for debugging
+ # json_get_var __DISPLAY "display_name" # for debugging
+ json_get_var __NAME "name"
+ json_get_var __TYPE "type"
+ if [ "$__NAME" = "$domain" ]; then
+ # we must verify IPv4 and IPv6 because there might be both for the same host
+ [ \( $use_ipv6 -eq 0 -a "$__TYPE" = "A" \) -o \( $use_ipv6 -eq 1 -a "$__TYPE" = "AAAA" \) ] && {
+ __FOUND=1 # mark found
+ break # found leave for loop
+ }
+ fi
+ json_select ..
+ done
+ [ $__FOUND -eq 0 ] && {
+ # we don't need to continue trying to update cloudflare because record to update does not exist
+ # user has to setup record first outside ddns-scripts
+ write_log 14 "No valid record found at Cloudflare setup. Please create first!"
+ }
+ json_get_var __RECID "rec_id" # last thing to do get rec_id
+ json_cleanup # cleanup
+ write_log 7 "rec_id '$__RECID' detected for host/domain '$domain'"
+}
+
+# build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
+# for "rec_edit" to update IP address
+__URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
+__URL="${__URL}?a=rec_edit" # -d 'a=rec_edit'
+__URL="${__URL}&tkn=$password" # -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25'
+__URL="${__URL}&id=$__RECID" # -d 'id=9001'
+__URL="${__URL}&z=$__DOMAIN" # -d 'z=example.com'
+
+[ $use_ipv6 -eq 0 ] && __URL="${__URL}&type=A" # -d 'type=A' (IPv4)
+[ $use_ipv6 -eq 1 ] && __URL="${__URL}&type=AAAA" # -d 'type=AAAA' (IPv6)
+
+# handle subdomain or domain record
+[ -n "$__SUBDOM" ] && __URL="${__URL}&name=$__SUBDOM" # -d 'name=sub' (HOST/SUBDOMAIN)
+[ -z "$__SUBDOM" ] && __URL="${__URL}&name=$__DOMAIN" # -d 'name=example.com'(DOMAIN)
+
+__URL="${__URL}&content=$__IP" # -d 'content=1.2.3.4'
+__URL="${__URL}&service_mode=0" # -d 'service_mode=0'
+__URL="${__URL}&ttl=1" # -d 'ttl=1'
+
+# lets do the update
+do_transfer "$__URL" || return 1
+
+cleanup # cleanup tmp file
+json_load "$(cat $DATFILE)" # lets extract data
+json_get_var __RES "result" # cloudflare result of last request
+json_get_var __MSG "msg" # cloudflare error message
+[ "$__RES" != "success" ] && {
+ write_log 4 "'rec_edit' failed with error:\n$__MSG"
+ return 1
+}
+write_log 7 "Update of rec_id '$__RECID' successful"
+return 0
--- /dev/null
+#
+#.Distributed under the terms of the GNU General Public License (GPL) version 2.0
+#
+# script for sending updates to no-ip.com / noip.com
+#.2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
+#
+# This script is parsed by dynamic_dns_functions.sh inside send_update() function
+#
+# provider did not reactivate records, if no IP change was recognized
+# so we send a dummy (localhost) and a seconds later we send the correct IP addr
+#
+local __DUMMY
+local __UPDURL="http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
+# inside url we need username and password
+[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
+[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
+
+# set IP version dependend dummy (localhost)
+[ $use_ipv6 -eq 0 ] && __DUMMY="127.0.0.1" || __DUMMY="::1"
+
+# lets do DUMMY transfer
+write_log 7 "sending dummy IP to 'no-ip.com'"
+__URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
+ -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__DUMMY#g")
+[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
+
+do_transfer "$__URL" || return 1
+
+write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
+# analyse provider answers
+# "good [IP_ADR]" = successful
+# "nochg [IP_ADR]" = no change but OK
+grep -E "good|nochg" $DATFILE >/dev/null 2>&1 || return 1
+
+# lets wait a seconds
+sleep 1
+
+# now send the correct data
+write_log 7 "sending real IP to 'no-ip.com'"
+__URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
+ -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
+[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
+
+do_transfer "$__URL" || return 1
+
+write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
+# analyse provider answers
+# "good [IP_ADR]" = successful
+# "nochg [IP_ADR]" = no change but OK
+grep -E "good|nochg" $DATFILE >/dev/null 2>&1
+return $? # "0" if "good" or "nochg" found
+