1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/geekpi-pyDNSpod

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
dnspod_os.py 1.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
richard.gk Отправлено 27.08.2013 11:16 c338eb4
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import httplib, urllib
import socket
import time
params = dict(
login_email="Admin@dnspod.cn", # replace with your email替换为邮箱账号地址
login_password="password", # replace with your password替换为密码
format="json",
domain_id=100, # replace with your domain_od, can get it by API Domain.List替换为对于id
record_id=100, # replace with your record_id, can get it by API Record.List
sub_domain="mail", # replace with your sub_domain替换为子域名,根域名用@
record_line="默认",
)
current_ip = None
def ddns(ip):
params.update(dict(value=ip))
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/json"}
conn = httplib.HTTPSConnection("dnsapi.cn")
conn.request("POST", "/Record.Ddns", urllib.urlencode(params), headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
print data
conn.close()
return response.status == 200
def getip():
sock = socket.create_connection(('ns1.dnspod.net', 6666))
ip = sock.recv(16)
sock.close()
return ip
if __name__ == '__main__':
while True:
try:
ip = getip()
print ip
if current_ip != ip:
if ddns(ip):
current_ip = ip
except Exception, e:
print e
pass
time.sleep(30)

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/geekpi-pyDNSpod.git
git@api.gitlife.ru:oschina-mirror/geekpi-pyDNSpod.git
oschina-mirror
geekpi-pyDNSpod
geekpi-pyDNSpod
master