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
import urllib2 | |
import socket | |
import time | |
class FreeDns: | |
def __init__(self): | |
self.IP_UPDATE='http://freedns.afraid.org/dynamic/update.php?' | |
self.MY_IP='http://darkstar.heliohost.org/ip.php' | |
self.WAIT_TIME=60 | |
def update(self,updateId): | |
urllib2.urlopen(self.IP_UPDATE + updateId) | |
def run(self,hostname,updateId): | |
while True: | |
html =urllib2.urlopen(self.MY_IP).read() | |
local= html[:html.find('<!--')] | |
host=socket.gethostbyaddr(hostname)[2][0] | |
if self.confirm(local, host): | |
break | |
else: | |
self.update(updateId) | |
time.sleep(60) | |
print 'ip update ok' | |
def confirm(self,local, host): | |
if(local == host): | |
return True | |
else: | |
return False | |
def _main(): | |
HOST_NAME='gilpa.mooo.com' | |
ID='U3A2ZzYwTVRTTUlBQUlmZGRXazoyNDk4MTcy' | |
freeDns = FreeDns() | |
freeDns.run(HOST_NAME,ID) | |
if __name__ == '__main__': _main() |
0 件のコメント:
コメントを投稿