Ejemplo n.º 1
0
 public void Remove(DomainConfigElement domain)
 {
     if (BaseIndexOf(domain) >= 0)
     {
         BaseRemove(domain.HostName);
     }
 }
Ejemplo n.º 2
0
        private void MakeRequest(DomainConfigElement domain)
        {
            domain.Timer.Interval = domain.LongDelay;

            try
            {
                string response = string.Empty;
                string content  = string.Empty;

                using (var client = new HttpClient())
                {
                    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://domains.google.com/nic/update?hostname=" + domain.HostName);
                    var byteArray = Encoding.ASCII.GetBytes(domain.UserName + ":" + domain.Password);
                    request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
                    request.Headers.UserAgent.ParseAdd("Chrome/57.0.2987.133");

                    var task = client.SendAsync(request);
                    task.Wait();

                    content  = task.Result.Content.ReadAsStringAsync().Result;
                    response = content.Split(' ')[0];
                }

                switch (response)
                {
                case "good":
                case "nochg":
                    EventLog.WriteEntry(EventSource, "Good update from domains.google.com for " + domain.HostName + ": " + content, EventLogEntryType.Information);
                    break;

                case "911":
                    // google error, wait 10 minutes for retry
                    domain.Timer.Interval = domain.ShortDelay;
                    break;

                default:
                    // some other issue
                    EventLog.WriteEntry(EventSource, "Failure update from domains.google.com for " + domain.HostName + ": " + content, EventLogEntryType.Error);
                    break;
                }
            }
            catch (Exception ex)
            {
                domain.Timer.Interval = domain.ShortDelay;
                EventLog.WriteEntry(EventSource, "Failure update trying to contact domains.google.com for " + domain.HostName + ": " + ex.StackTrace.ToString(), EventLogEntryType.Error);
            }
        }
Ejemplo n.º 3
0
 public int IndexOf(DomainConfigElement domain)
 {
     return(BaseIndexOf(domain));
 }
Ejemplo n.º 4
0
 public void Add(DomainConfigElement domain)
 {
     BaseAdd(domain);
 }
Ejemplo n.º 5
0
        public DomainsCollection()
        {
            DomainConfigElement domain = (DomainConfigElement)CreateNewElement();

            Add(domain);
        }