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 +}