![]() Next you need to setup tasker to run this command when your device connects to WiFi. Once you have curl you can simply do things like updating your opendns ip curl -u opendnsusername:password The guide to install curl can be found here No configuration beyond that.įor Android users busybox versions of wget are way behind and don't have options to use user names and passwords, so we will have to install and use cURL It's as simple as signing up for an account and adding opendns to your services. Logging.I went through a free web service called dnsomatic (run by the folks at opendns) info( "Success updating ip address from " + dnsRecordAddress + " to " + currentWanIp) patchDNSRecord( dnsRecordId, curDict, dnsRecordName, currentWanIp, dnsRecordTtl, dnsRecordProxied) debug( "Cloudflare dns info: " + str( dnsRecord))ĬfActions. something strange happenedĮxcept requests. error( "Error while retrieving the dns record: no dns record found!")ĬurDict = dtSecondsFromNow( curDict) #not able to update the dns record. If dnsRecords = curDict and dnsRecords = curDict: error( "Trying to access the ip finder service failed: " + str( e)) DNSException as e:ĬurDict = dtSecondsFromNow( curDict) debug( "Got current Wan ip: " + currentWanIp)ĬurDict = dtSecondsFromNow( curDict) #am I disconnected? Retry more often, the ip address may have changed!Ĭontinue #Restart the loop because there is no IP address to be usedĮxcept dns. info( "Updating " + zoneIdentifier + ", record name " + curDict + ", record type " + curDict) debug( "Sleeping for " + str( secToSleep) + " seconds") SecToSleep = positiveSecUntilExpire( curDict) #how long it will sleep ZoneIdentifier = getFirstExpiringZoneId( zIDict) #take the first zone id to expire based on its expireDate fieldĬfActions = CloudflareApiActions( CloudflareApi( curDict), zoneIdentifier) Here 'now' is used because the zone hasn't been updated yet. #expireDate is the expire date/time to update this zone's fields. With open( configurationFilePath, "w") as configFile:Ĭonfig = error( "Configuration file " + configurationFilePath + " not found! Creating an empty one.") basicConfig( filename = loggingFilePath, encoding = 'utf-8', level = logging. excepthook = handle_exception #Log exceptions even if not caught LoggingFilePath = "cloudflare-ddns-updater.log" total_seconds() *( timeDiff > timedelta( seconds = 0))ĬonfigurationFilePath = "cloudflare-ddns-updater.ini" """Returns the difference in seconds between expireDate and now, only if it is positive. """Returns a datetime object containing now time + seconds""" min #start from the lowest valueĬurTimeDelta = now - zoneIdDict """Returns the zone identifier with the nearest expiration time, if given a zoneIdDict type list (see below code).""" error( "Uncaught exception: ", exc_info =( exc_type, exc_value, exc_traceback)) _excepthook_( exc_type, exc_value, exc_traceback) If issubclass( exc_type, KeyboardInterrupt): #don't log KeyboardInterrupt. error( "Error while recovering the " + recordType + " wan ip address: " + str( wan_ip))ĭef handle_exception( exc_type, exc_value, exc_traceback): ip_address( wan_ip) #fails if the ip address is invalid #Getting external ip address using the opendns service """Wan ip source has returned an invalid response""" From cloudflare_api_interface import * #module in this folderįrom datetime import timedelta as timedelta
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |