public override void Update(HostConfig HC, IPAddress ipAddress) { if (HC == null) { throw new ArgumentNullException("HC"); } if (ipAddress == null) { throw new ArgumentNullException("ipAddress"); } using (RMWebClient WC = new RMWebClient()) { string Url = "https://www.dtdns.com/api/autodns.cfm"; Url += "?id=" + Uri.EscapeDataString(HC.Hostname); Url += "&pw=" + Uri.EscapeDataString(HC.Password.GetPlainText()); Url += "&ip=" + ipAddress.ToString(); Url += "&client=PDDNS"; string ResponseText = WC.DownloadString(Url).Trim(); if (!ResponseText.Contains(ipAddress.ToString())) { HC.Disabled = true; HC.DisabledReason = ResponseText; HC.Save(); Logging.instance.LogError("Unable to update host \"" + HC.Hostname + "\" (" + HC.Provider.ToString() + "): " + HC.DisabledReason); } } }
public override void Update(HostConfig HC, IPAddress ipAddress) { if (HC == null) { throw new ArgumentNullException("HC"); } if (ipAddress == null) { throw new ArgumentNullException("ipAddress"); } using (RMWebClient WC = new RMWebClient()) { WC.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(HC.Username + ":" + HC.Password.GetPlainText())); WC.UseDefaultCredentials = false; WC.UserAgent = ProcessUtils.CompanyName + " " + ProcessUtils.ProductName + "/" + ProcessUtils.ProductVersion + " [email protected]"; string Url = "https://dynupdate.no-ip.com/nic/update"; Url += "?hostname=" + Uri.EscapeDataString(HC.Hostname); Url += "&myip=" + ipAddress.ToString(); string ResponseText = WC.DownloadString(Url).Trim().ToLower(); if (ResponseText.Contains(ipAddress.ToString())) { if (ResponseText.Contains("nochg")) { Logging.instance.LogWarning("Host \"" + HC.Hostname + "\" (" + HC.Provider.ToString() + ") successfully updated, but returned NOCHG response. Too many of these could cause your account to be banned by the provider."); } } else { HC.Disabled = true; switch (ResponseText) { case "nohost": HC.DisabledReason = "Hostname supplied does not exist under specified account"; break; case "badauth": HC.DisabledReason = "Invalid username password combination"; break; case "badagent": HC.DisabledReason = "Client disabled."; break; case "!donator": HC.DisabledReason = "An update request was sent including a feature that is not available to that particular user such as offline options."; break; case "abuse": HC.DisabledReason = "Username is blocked due to abuse. Either for not following our update specifications or disabled due to violation of the No-IP terms of service."; break; case "911": Logging.instance.LogWarning("Unable to update host \"" + HC.Hostname + "\" (" + HC.Provider.ToString() + "): A fatal error on the provider's side such as a database outage. Will retry in 1 hour."); return; default: HC.DisabledReason = "An unknown response code was received: \"" + ResponseText + "\""; break; } HC.Save(); Logging.instance.LogError("Unable to update host \"" + HC.Hostname + "\" (" + HC.Provider.ToString() + "): " + HC.DisabledReason); } } }
void cmdRetrieve_Click(object sender, EventArgs e) { if (!Dialog.ValidateIsEmailAddress(txtEmailAddress)) { return; } if (!Dialog.ValidateIsNotEmpty(txtAPIKey)) { return; } lvZoneRecords.Items.Clear(); using (RMWebClient WC = new RMWebClient()) { WC.ContentType = "application/xml"; WC.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(txtEmailAddress.Text.Trim() + ":" + txtAPIKey.Text.Trim())); WC.Headers["Accept"] = "application/xml"; WC.UseDefaultCredentials = false; // Get all zones try { string ZonesXml = WC.DownloadString("https://pointhq.com/zones"); XmlSerializer XS = new XmlSerializer(typeof(Point.zones)); Point.zones Zones = null; using (TextReader TR = new StringReader(ZonesXml)) { Zones = (Point.zones)XS.Deserialize(TR); } // Now get all records for each zone foreach (Point.zonesZone Zone in Zones.zone) { string ZoneRecordsXml = WC.DownloadString("https://pointhq.com/zones/" + Zone.id.ToString() + "/records"); XS = new XmlSerializer(typeof(Point.zonerecords)); Point.zonerecords ZoneRecords = null; using (TextReader TR = new StringReader(ZoneRecordsXml)) { ZoneRecords = (Point.zonerecords)XS.Deserialize(TR); } foreach (Point.zonerecordsZonerecord ZoneRecord in ZoneRecords.zonerecord) { if (ZoneRecord.recordtype.ToUpper() == "A") { ListViewItem LVI = new ListViewItem(ZoneRecord.name.TrimEnd('.')); LVI.SubItems.Add(ZoneRecord.zoneid.ToString()); LVI.SubItems.Add(ZoneRecord.id.ToString()); lvZoneRecords.Items.Add(LVI); } } } } catch (Exception ex) { Logging.instance.LogException("Error retrieving Point zone records", ex); Dialog.Error("Error retrieving hostnames:\r\n\r\n" + ex.Message, "Error"); } } }