Ejemplo n.º 1
0
 private void updateIp()
 {
     foreach (var item in config.DOMAIN)
     {
         string         sub_dom = item.split("\\.")[0];
         string         dom     = item.split("\\.")[1] + "." + item.split("\\.")[2];
         string         dom_id  = "";
         string         old_ip  = "";
         string         records = "";
         EasyHttpClient ehc     = new EasyHttpClient();
         var            re      = ehc.Post("https://dnsapi.cn/Record.List", "", "login_token=" + config.TokenId + "," + config.Token + "&format=json&domain=" + dom + "&sub_domain=" + sub_dom + "&record_type=A");
         if (re.html.GetVal("code\":\"", "\"") == "1")
         {
             records = re.html.GetVal("records\"", "type");
             dom_id  = records.GetVal("id\":\"", "\"");
             old_ip  = records.GetVal("value\":\"", "\"");
             if (old_ip != config.Ip)
             {
                 var re2 = ehc.Post("https://dnsapi.cn/Record.Ddns", "", "login_token=" + config.TokenId + "," + config.Token + "&format=json&domain=" + dom + "&record_type=A&record_line=默认&sub_domain=" + sub_dom + "&value=" + config.Ip + "&record_id=" + dom_id);
                 this.Text = "DNSPOD 动态域名更新程序 - " + DateTime.Now.ToString("HH:mm") + " - DnsPod更新成功";
             }
             else
             {
                 this.Text = "DNSPOD 动态域名更新程序 - " + DateTime.Now.ToString("HH:mm") + " - IP无需更新";
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void GetChangeIp()
        {
            EasyHttpClient             ehc         = new EasyHttpClient();
            var                        re          = ehc.Get("https://service-reqw3pvy-1252879367.gz.apigw.tencentcs.com/release/ipAddr");
            DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(ips));
            ips                        ip          = (ips)deseralizer.ReadObject(new MemoryStream(re.ResponseByte));// //反序列化ReadObject
            string                     NowIp       = ip.ip;

            if (NowIp != config.Ip)
            {
                config.Ip = NowIp;
                updateIp();
            }
            config.Addr = ip.loc;
        }