卖逼视频免费看片|狼人就干网中文字慕|成人av影院导航|人妻少妇精品无码专区二区妖婧|亚洲丝袜视频玖玖|一区二区免费中文|日本高清无码一区|国产91无码小说|国产黄片子视频91sese日韩|免费高清无码成人网站入口

DNSPod的API接口實現DDNS客戶端

將dnspodsh復制到/usr/bin下設置成可執(zhí)行屬性,并在/etc/rc.local中加入下面一行即可實現你自己的免費DDNS:/usr/bin/dnspodsh dnspod_name dns

將dnspodsh復制到/usr/bin下設置成可執(zhí)行屬性,并在/etc/rc.local中加入下面一行即可實現你自己的免費DDNS:
/usr/bin/dnspodsh dnspod_name dnspod_passwaord &>/dev/null

保存時注意使用LINUX格式和UTF8編碼
設置域名的地方有2個數組,如果只有一個域名的話可以這么設置:
domainList[0]='baidu.com * @'
domainList[1]='baidu.com www'

文件名:dnspodsh

內容:

#!/bin/bash

##############################
# dnspodsh v0.3
# 基于dnspod api構架的bash ddns客戶端
# 作者:zrong(zengrong.net)
# 詳細介紹:http://zengrong.net/post/1524.htm
# 創(chuàng)建日期:2012-02-13
# 更新日期:2012-03-11
##############################

login_email=${1:?'必須提供登錄名'}
login_password=${2:?'必須提供密碼'}
format="json"
lang="en"
userAgent="dnspodsh/0.3(zrongzrong@gmail.com)"
commonPost="login_email=$login_email&login_password=$login_password&format=$format&lang=$lang"

apiUrl='https://dnsapi.cn/'
ipUrl='http://members.3322.org/dyndns/getip'

# 要處理的域名數組,每個元素代表一個域名的一組記錄
# 在數組的一個元素中,以空格分隔域名和子域名
# 第一個空格前為主域名,后面用空格分離多個子域名
# 如果使用泛域名,必須用*轉義
domainList[0]='domain1.com * @ www'
domainList[1]='domain2.com subdomain subdomain2'

# 多長時間比較一次ip地址
delay=300

# logfile
logDir='/var/log'
logFile=$logDir'/dnspodsh.log'
traceFile=$logDir'/dnspodshtrace.log'

# 檢測ip地址是否符合要求
checkip()
{
# ipv4地址
if [[ "$1" =~ ^([0-9]{1,3}.){3}[0-9]{1,3}$ ]];then
return 0
# ipv6地址
elif [[ "$1" =~ ^([?-fA-F]{1,4}:){7}[?-fA-F]{1,4}$|^:((:[?-fA-F]{1,4}){1,6}|:)$|^[?-fA-F]{1,4}:((:[?-fA-F]{1,4}){1,5}|:)$|^([?-fA-F]{1,4}:){2}((:[?-fA-F]{1,4}){1,4}|:)$|^([?-fA-F]{1,4}:){3}((:[?-fA-F]{1,4}){1,3}|:)$|^([?-fA-F]{1,4}:){4}((:[?-fA-F]{1,4}){1,2}|:)$|^([?-fA-F]{1,4}:){5}:([?-fA-F]{1,4})?$|^([?-fA-F]{1,4}:){6}:$ ]];then
return 0
fi
return 1
}

getUrl()
{
#curl -s -A $userAgent -d $commonPost$2 --trace $traceFile $apiUrl$1
curl -s -A $userAgent -d $commonPost$2 $apiUrl$1
}

getVersion()
{
getUrl "Info.Version"
}

getUserDetail()
{
getUrl "User.Detail"
}

writeLog()
{
if [ -w $logDir ];then
local pre=`date`
for arg in $@;do
pre=$pre't'$arg
done
echo -e $pre>>$logFile
fi
echo -e $1
}

getDomainList()
{
getUrl "Domain.List" "&type=all&offset=0&length=10"
}

# 根據域名id獲取記錄列表
# $1 域名id
getRecordList()
{
getUrl "Record.List" "&domain_id=$1&offset=0&length=20"
}

# 設置記錄
setRecord()
{
writeLog "set domain $3.$8 to new ip:$7"
local subDomain=$3
# 由于*會被擴展,在最后一步將轉義的*替換成*
if [ "$subDomain" = '*' ];then
subDomain='*'
fi
local request="&domain_id=$1&record_id=$2&sub_domain=$sub

標簽: