#12500: Add cloudflare.com to DDNS Scripts
--------------------------+----------------------------------
  Reporter:  easisee@…    |      Owner:  developers
      Type:  enhancement  |     Status:  new
  Priority:  normal       |  Milestone:  Chaos Calmer (trunk)
 Component:  packages     |    Version:  Trunk
Resolution:               |   Keywords:
--------------------------+----------------------------------

Comment (by chris5560):

 Paul,
 I found a short term solution based on ddns-scripts 2.0.1-6.
 I offer here 2 changes to existing scripts for testing:

 /usr/lib/ddns/dynamic_dns_updater.sh at below line 162 new should be
 {{{
 # determine what update url we're using if a service_name is supplied
 # otherwise update_url is set inside configuration (custom service)
 # or update_script is set inside configuration (custom update script)
 [ -n "$service_name" ] && get_service_url update_url
 [ -z "$update_url" -a -z "$update_script" ] && critical_error "no
 update_url found/defined or no custom update_script defined"
 [ -n "$update_script" -a ! -f "$update_script" ] && critical_error "custom
 update_script not found"

 #kill old process if it exists & set new pid file
 }}}

 /usr/lib/ddns/dynamic_dns_functions.sh at below line 590 replace
 send_update() function with
 {{{
 send_update() {
         # $1    # IP to set at DDNS service provider
         local __IP

         # verify given IP / no private IPv4's / no IPv6 addr starting with
 fxxx of with ":"
         [ $use_ipv6 -eq 0 ] && __IP=$(echo $1 | grep -v -E
 "(^0|^10\.|^127|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168)")
         [ $use_ipv6 -eq 1 ] && __IP=$(echo $1 | grep "^[0-9a-eA-E]")
         [ -z "$__IP" ] && critical_error "Invalid or no IP '$1' given"

         if [ -z "$service_name" -a -n "$update_script" ]; then
                 verbose_echo " custom update =: parsing script
 '$update_script'"
                 . $update_script
         else
                 local __URL __ANSWER __ERR __USER __PASS

                 # do replaces in URL
                 __urlencode __USER "$username"  # encode username, might
 be email or something like this
                 __urlencode __PASS "$password"  # encode password, might
 have special chars for security reason
                 __URL=$(echo $update_url | sed -e
 "s#\[USERNAME\]#$__USER#g" -e "s#\[PASSWORD\]#$__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 __ANSWER "$__URL"
                 __ERR=$?
                 [ $__ERR -gt 0 ] && {
                         verbose_echo "\n!!!!!!!!! ERROR =: Error sending
 update to DDNS Provider\n"
                         return 1
                 }
                 verbose_echo "   update send =: DDNS Provider
 answered\n$__ANSWER"
                 return 0
         fi
 }
 }}}

 Inside /etc/config/ddns insert a new '''option update_url
 '/path/to/script'''' and remove '''option service_name'''

 The idea behind this is to offer custom scripts for special services like
 cloudflare.update also located inside /usr/lib/ddns directory.
 Inside these scripts you can do all actions you need and can still access
 all existing variables and functions out of dynamic_dns_functions.
 Options to be set inside /etc/config/ddns shoud start with the service
 name the scripts is for like
 cloudflare_subdomain, cloudflare_xyz
 This hopefully makes it easier in later versions of scripts or luci app to
 identify them.
 Would you provide such cloudflare.update script ?

 If you agree this short term solution, I will create a pull request to
 update both scripts in trunk.

 Thanks
 Christian

--
Ticket URL: <https://dev.openwrt.org/ticket/12500#comment:16>
OpenWrt <http://openwrt.org>
Opensource Wireless Router Technology
_______________________________________________
openwrt-tickets mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-tickets

Reply via email to