|
| 1 | +############## Script FreeDNS.afraid.org ################## |
| 2 | +############## PARSER EDITION ################## |
| 3 | +############## CREATED LESHIY_ODESSA ################## |
| 4 | +############## Improved by SEAN SCARFO ################## |
| 5 | +# Specify your domain or subdomain. |
| 6 | +:global "dns-domain" "et.phone.home" |
| 7 | + |
| 8 | +# Define IP checker website variable. Any website that returns only the ip address in text format. examples listed |
| 9 | +#https://www.trackip.net/ip/ |
| 10 | +#http://wgetip.com/ |
| 11 | +#https://api.ipify.org/ |
| 12 | +#If not pointing to a specific file, must end in a / |
| 13 | +# Case sensitive. |
| 14 | +:global "wanChecker" "http://wgetip.com/" |
| 15 | + |
| 16 | +# Specify the "Direct URL", which is https://freedns.afraid.org/dynamic/ |
| 17 | +# In front of the sign "?" put a backslash "\". |
| 18 | +:global "direct-url" "https://freedns.afraid.org/dynamic/update.php\?123456789" |
| 19 | + |
| 20 | +# Specify the URL API "ASCII" |
| 21 | +# Log in under your account and open the page https://freedns.afraid.org/api/ |
| 22 | +# Then copy the URL of your site - Available API Interfaces : ASCII (!!! NOT XML !!!) |
| 23 | +# ATTENTION!!!! Before the question mark, put a backslash "\". |
| 24 | +:global "api-url" "https://freedns.afraid.org/api/\?action=getdyndns&v=2&sha=123456789" |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +# !!!!!!!!!!!!!!!!! Nothing more do not need to edit!!!!!!!!!!!!!!!!! |
| 29 | +:global "current-ip" |
| 30 | +:global "dns-domain-ip" |
| 31 | +:if ([:len $"current-ip"] <7) do={ |
| 32 | + :log error ("current-ip variable has no value, setting it to 1.1.1.1"); |
| 33 | + :global "current-ip" 1.1.1.1; |
| 34 | +} else={ |
| 35 | + :log warning ("current IP varaible exists and has a value") |
| 36 | + |
| 37 | +# Compare global IP variables |
| 38 | +# Compare the external IP with the IP address of the DNS domain. |
| 39 | + :if ($"current-ip" = $"dns-domain-ip") do={ |
| 40 | + :log warning ("current-ip matches dns-domain-ip, script is done!") |
| 41 | + } else={ |
| 42 | + |
| 43 | +#Fetch Last Known IP info from FreeDNS |
| 44 | + /tool fetch url=$"api-url" dst-path="/freedns.txt" |
| 45 | +#Fetch Current WAN IP from the Web |
| 46 | + /tool fetch url="$wanChecker" dst-path="/wanCheckerfile.txt" |
| 47 | + |
| 48 | +# Find out the IP address of the domain using the API and parsing. |
| 49 | +# Split the file |
| 50 | + :local "result" [/file get freedns.txt contents] |
| 51 | + :local "startloc" ([:len $"dns-domain"] + 1) |
| 52 | + :local "endloc" ([:find $"result" "https" -1] -1) |
| 53 | + :global "dns-domain-ip" [:pick $"result" $"startloc" $"endloc"] |
| 54 | + |
| 55 | +# Find the current IP address on the external interface |
| 56 | + :global "current-ip" [/file get wanCheckerfile.txt contents] |
| 57 | + |
| 58 | +# Send new IP to freedns.afraid.org our external IP by using Direct URL |
| 59 | + :log error ("Service Dynamic DNS: old IP address $"dns-domain-ip" for $"dns-domain" CHANGED to -> $"current-ip"") |
| 60 | + /tool fetch mode=https url=$"direct-url" keep-result=no |
| 61 | + } |
| 62 | +} |
| 63 | +##############Script FreeDNS.afraid.org################## |
0 commit comments