国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

DNSPod的API接口實現(xiàn)DDNS客戶端

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

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

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

文件名:dnspodsh

內(nèi)容:

#!/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'

# 要處理的域名數(shù)組,每個元素代表一個域名的一組記錄
# 在數(shù)組的一個元素中,以空格分隔域名和子域名
# 第一個空格前為主域名,后面用空格分離多個子域名
# 如果使用泛域名,必須用*轉(zhuǎn)義
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"
}

# 根據(jù)域名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
# 由于*會被擴展,在最后一步將轉(zhuǎn)義的*替換成*
if [ "$subDomain" = '*' ];then
subDomain='*'
fi
local request="&domain_id=$1&record_id=$2&sub_domain=$sub

標簽: