Last active
July 23, 2018 21:13
-
-
Save ishrakr/a32dc64cb1ceeed728f3d59218973b40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please note this no longer works because APIv1 has been deprecated. | |
:global WANInterface "pppoe-out1" | |
:local CFdomain "" | |
:local CFzone "" | |
:local CFemail "" | |
:local CFtkn "" | |
:local CFid "" | |
:local CFrecordType "A" | |
:local CFserviceMode "0" | |
:local CFttl "120" | |
:local resolvedIP "" | |
:global WANip "" | |
:local currentIP [/ip address get [/ip address find interface=$WANInterface ] address]; | |
:set WANip [:pick $currentIP 0 [:find $currentIP "/"]]; | |
:set resolvedIP [:resolve $CFdomain]; | |
:local CFurl "https://www.cloudflare.com/api_json.html\3F" | |
:set CFurl ($CFurl . "email=$CFemail&tkn=$CFtkn&a=rec_edit"); | |
:set CFurl ($CFurl . "&id=$CFid&z=$CFzone&name=$CFdomain"); | |
:set CFurl ($CFurl . "&type=$CFrecordType&service_mode=$CFserviceMode&ttl=$CFttl"); | |
:if ($resolvedIP != $WANip) do={ | |
:log info ("cf updater: updating record to $CFDomain = $WANip") | |
/tool fetch mode=https url="$CFurl&content=$WANip" keep-result=no | |
/ip dns cache flush | |
} else={ | |
:log info "cf updater: record up to date" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment