花生壳确实不给力啊,免费的都不支持MX记录
我用的是3322的DDNS,但官方软件也不给力,经常自动关闭或不检测IP更新
只好自己操刀,简单写了一个,凑合着用吧
#include <Services.au3>
$sServiceName = "DDNS"
$User = IniRead(@ScriptDir & "\Config.ini", "Set", "User", "")
$Passwor = IniRead(@ScriptDir & "\Config.ini", "Set", "Password", "")
$Domain = IniRead(@ScriptDir & "\Config.ini", "Set", "Domain", "")
$DmIp = IniRead(@ScriptDir & "\Config.ini", "Set", "Ip", "")
If $cmdline[0] > 0 Then
Switch $cmdline[1]
Case "install", "-i", "/i"
InstallService()
Case "remove", "-u", "/u", "uninstall"
RemoveService()
Case Else
ConsoleWrite("说明 : " & @CRLF)
ConsoleWrite(" -i : 安装服务" & @CRLF)
ConsoleWrite(" -u : 卸载服务" & @CRLF)
Exit
EndSwitch
EndIf
While 1
Sleep(3000)
If _GetIP() <> $DmIp Then
IniWrite (@ScriptDir & "\Config.ini", "Set", "Ip", _GetIP())
;如果外网地址有变动,则更新域名IP
$oHTTP = ObjCreate("microsoft.xmlhttp")
$oHTTP.Open("post","http://"&$User&":"&$Passwor&"@members.3322.org/dyndns/update?system=dyndns&hostname="&$Domain&"&myip="&_GetIP()&"&wildcard=OFF&mx="&$Domain&"&backmx=NO&offline=NO",false)
$oHTTP.Send
EndIf
WEnd
_Service_init($sServiceName)
Func _GetIP()
$ipurl = 'http://www.ip138.com/ip2city.asp' & @cr & _
'http://www.123cha.com/ip/' & @cr & _
'http://ip.91cool.net/ip.php?type=ip' & @cr & _
'http://fw.qq.com/ipaddress'
$url = StringSplit($ipurl, @cr)
For $i = 1 to $url[0]
If InetGet($url[$i], @TempDir & "\~ip.tmp") Then
$ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
FileDelete(@TempDir & "\~ip.tmp")
$ip = StringRegExp($ip, '((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)', 2)
If not @error then Return $ip[0]
EndIf
Next
SetError(1)
Return -1
EndFunc
Func InstallService()
_Service_Create($sServiceName, "3322 Dynamic Domain Name Server", $SERVICE_WIN32_OWN_PROCESS, $SERVICE_DEMAND_START, $SERVICE_ERROR_IGNORE,'"' & @ScriptFullPath & '"')
Exit
EndFunc ;==>InstallService
Func RemoveService()
_Service_Stop($sServiceName)
_Service_Delete($sServiceName)
Exit
EndFunc ;==>RemoveService
|