Last active
April 16, 2016 07:09
-
-
Save zigzag32/8ffcc108579b37f6806e to your computer and use it in GitHub Desktop.
A simple Google Domains Dynamic DNS IP updater.
This file contains hidden or 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
GoogleDomainsMgr |
This file contains hidden or 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
<component name="ProjectDictionaryState"> | |
<dictionary name="robert"> | |
<words> | |
<w>ipaddress</w> | |
</words> | |
</dictionary> | |
</component> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
<OptionsSetting value="true" id="Add" /> | |
<OptionsSetting value="true" id="Remove" /> | |
<OptionsSetting value="true" id="Checkout" /> | |
<OptionsSetting value="true" id="Update" /> | |
<OptionsSetting value="true" id="Status" /> | |
<OptionsSetting value="true" id="Edit" /> | |
<ConfirmationsSetting value="0" id="Add" /> | |
<ConfirmationsSetting value="0" id="Remove" /> | |
</component> | |
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.10 (C:\Python\2.7.10\python.exe)" project-jdk-type="Python SDK" /> | |
</project> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/GoogleDomainsMgr.iml" filepath="$PROJECT_DIR$/.idea/GoogleDomainsMgr.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="" vcs="" /> | |
</component> | |
</project> |
This file contains hidden or 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
__author__ = 'Robert P. aka zigzag32' | |
import requests | |
import time | |
def subdomainupdate(username, password, subdomain): | |
# auto fetch | |
ipaddress = requests.get('https://domains.google.com/checkip') | |
# URL set up | |
userpass = username + ':' + password | |
domainip = subdomain + '&myip=' + ipaddress.content | |
url = 'https://' + userpass + '@domains.google.com/nic/update?hostname=' + domainip | |
# updating Sub Domain Info | |
finish = requests.get(url) | |
if 'nochg' in finish.content: | |
print 'The supplied IP address is already set for this host. You should not attempt another update until your IP address changes.' | |
updateip(finish.content) | |
elif 'good' in finish.content: | |
print 'The Ip address was updated successfully. You should not attempt another update until your IP address changes.' | |
elif 'nohost' in finish.content: | |
print 'The hostname does not exist, or does not have Dynamic DNS enabled.' | |
elif 'badauth' in finish.content: | |
print 'The username / password combination is not valid for the specified host.' | |
elif 'notfqdn' in finish.content: | |
print 'The supplied hostname is not a valid fully-qualified domain name.' | |
elif 'abuse' in finish.content: | |
print 'Dynamic DNS access for the hostname has been blocked due to failure to interpret previous responses correctly.' | |
elif 'badagent' in finish.content: | |
print 'Your Dynamic DNS client is making bad requests. Ensure the user agent is set in the request, and that you are only attempting to set an IPv4 address. IPv6 is not supported.' | |
elif '911' in finish.content: | |
print 'An error happened on our end. Wait 5 minutes and retry.' | |
time.sleep(600) | |
def gdipupdate(username, password, subdomain, refreshtime): | |
ipaddress = requests.get('https://domains.google.com/checkip') | |
print 'updating ' + subdomain + ' every ' + str(round(refreshtime / 60)) + ' minutes' | |
while True: | |
subdomainupdate(username, password, subdomain) | |
while ipcheck(ipaddress.content): | |
time.sleep(refreshtime) | |
def ipcheck(ip): | |
if ipadr == ip: | |
print('The Ip Address has not changed, no action will be taken.') | |
return True | |
else: | |
print('The Ip Address has changed, updating the Ip Address.') | |
return False | |
def updateip(nch): | |
ipstr = nch | |
txt,ipm = ipstr.split(' ') | |
global ipadr | |
ipadr = ipm | |
gdipupdate('AAAAAAAAAAAAAA', 'BBBBBBBBBBBBBBB', 'test.zigzag32.com', 3600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment