Beispiel #1
0
        public static void Refresh(IDomainRecord domainRecord, DDNSConfig dnsConfig)
        {
            var current_ip = IPHelper.CurrentIp();
            var records    = domainRecord.GetRecords(dnsConfig.domain);

            if (!string.IsNullOrEmpty(dnsConfig.ignoreRR.Trim()))
            {
                var igs = dnsConfig.ignoreRR.Trim().Split("|");
                records = records.Where(x => x.Type == "A" && !igs.Contains(x.RR));
            }

            if (!records.Any(x => x.Value != current_ip))
            {
                Console.WriteLine($"{DateTime.Now} ip没有改变 {current_ip}");
                return;
            }

            Console.WriteLine($"{DateTime.Now} 更新A解析记录 {current_ip}");

            // 更新记录
            foreach (var item in records)
            {
                //item.Value = current_ip;
                //domainRecord.UpdateRecord(item);
            }
        }
Beispiel #2
0
        public void RemoveDdns(int recordid)
        {
            Predicate <DDNSConfig> predicate2 = null;
            Predicate <DDNSConfig> match      = null;

            lock (this)
            {
                if (match == null)
                {
                    if (predicate2 == null)
                    {
                        predicate2 = item => item.RecordId == recordid;
                    }
                    match = predicate2;
                }
                DDNSConfig config = this._Ddnses.Find(match);
                if (config != null)
                {
                    this._Ddnses.Remove(config);
                }
            }
        }
Beispiel #3
0
        public void AddDdns(DDNSConfig item)
        {
            Predicate <DDNSConfig> predicate2 = null;
            Predicate <DDNSConfig> match      = null;

            lock (this)
            {
                if (match == null)
                {
                    if (predicate2 == null)
                    {
                        predicate2 = x => x.RecordId == item.RecordId;
                    }
                    match = predicate2;
                }
                DDNSConfig config = this._Ddnses.Find(match);
                if (config != null)
                {
                    this._Ddnses.Remove(config);
                }
                this._Ddnses.Add(item);
            }
        }
Beispiel #4
0
 public AliyunDomainRecord(DDNSConfig config)
 {
     this.accessKey    = config.accessKey;
     this.accessSecret = config.accessSecret;
 }