From 150510ee7a257aadafdac08fc3fb942516e51a41 Mon Sep 17 00:00:00 2001 From: Imi <27138272+iminet@users.noreply.github.com> Date: Mon, 18 Jan 2021 09:22:36 +0100 Subject: [PATCH] Some buf fixes --- Iminetsoft.Godaddy.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Iminetsoft.Godaddy.cs b/Iminetsoft.Godaddy.cs index 36d905f..d6bdf78 100644 --- a/Iminetsoft.Godaddy.cs +++ b/Iminetsoft.Godaddy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net; using System.IO; using System.Text; @@ -29,10 +29,23 @@ namespace Iminetsoft public string Data { get; set; } = String.Empty; public int Priority { get; set; } = 0; + public string UserAgent { get; set; } = "Iminetsoft.Godaddy.Net"; + public Dictionary ResponseHeaders { get; private set; } = new Dictionary(); public string ExceptionMessage { private set; get; } = String.Empty; public StatusCodes StatusCode = StatusCodes.EmptyResponse; + public Godaddy(){ } + public Godaddy(string domain, string name, RecordTypes type, int ttl, string key, string secret) + { + Domain = (domain.Length > 0 ? domain.Trim() : Domain); + Name = (name.Length > 0 ? name.Trim() : Name); + Type = type; + Ttl = (ttl >= 10 && ttl <=3600 ? ttl : Ttl); + Key = (key.Length > 0 ? key.Trim() : Key); + Secret = (secret.Length > 0 ? secret.Trim() : Secret); + } + /// /// Gets the current data of the specified domain and DNS record /// @@ -71,8 +84,9 @@ namespace Iminetsoft ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest webreq = (HttpWebRequest)System.Net.WebRequest.Create(apiurl); webreq.Headers.Add("Authorization", $"sso-key {Key}:{Secret}"); - webreq.Headers.Add("Content-Type", "application/json"); - webreq.Headers.Add("accept", "application/json"); + webreq.ContentType = "application/json"; + webreq.Accept = "application/json"; + webreq.UserAgent = UserAgent; if (UpdateData == true && RecordToJson().Length > 0) { @@ -146,4 +160,4 @@ namespace Iminetsoft return JsonConvert.SerializeObject(new object[1] { pushrecord }); } } -} \ No newline at end of file +}