private void DdnsMethod(object para) { DomainPara dPara = (DomainPara)para; while (true) { //获取外网IP dPara.Ip = ExtenalIp.Value; ShowIp?.Invoke(dPara.Ip); if (string.IsNullOrEmpty(dPara.Ip)) { WriteLog?.Invoke($"获取外网IP,本次解析停止,将于下次解析重试!"); Thread.Sleep(Config.SpanTime * 60 * 1000); continue; } //开始解析 RecordType record = GetDomainRecords(dPara.Domain); if (record == null) { if (AddDomainRecords(dPara.Domain, dPara.Ip) != null) { WriteLog?.Invoke($"未找到相关的解析记录,已新增解析记录!"); } else { WriteLog?.Invoke("修改解析记录失败,请检查网络和AccessKey是否正确!"); } } else { if (record.Value == dPara.Ip) { WriteLog?.Invoke("更新IP与记录IP相同,暂不更新!"); } else { UpdateDomainRecord(record, dPara.Ip); } } Thread.Sleep(Config.SpanTime * 60 * 1000); } }
private void GetExIp() { string ip = ""; try { ip = ExtenalIp.Value; } catch { } ShowIp?.Invoke(ip); if (this.InvokeRequired) { this.Invoke(new Action(() => { this.Close(); })); } else { this.Close(); } }