Some buf fixes

This commit is contained in:
Imi 2021-01-18 09:22:36 +01:00 committed by GitHub
parent df774e12cd
commit 150510ee7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Net; using System.Net;
using System.IO; using System.IO;
using System.Text; using System.Text;
@ -29,10 +29,23 @@ namespace Iminetsoft
public string Data { get; set; } = String.Empty; public string Data { get; set; } = String.Empty;
public int Priority { get; set; } = 0; public int Priority { get; set; } = 0;
public string UserAgent { get; set; } = "Iminetsoft.Godaddy.Net";
public Dictionary<string, string> ResponseHeaders { get; private set; } = new Dictionary<string, string>(); public Dictionary<string, string> ResponseHeaders { get; private set; } = new Dictionary<string, string>();
public string ExceptionMessage { private set; get; } = String.Empty; public string ExceptionMessage { private set; get; } = String.Empty;
public StatusCodes StatusCode = StatusCodes.EmptyResponse; 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);
}
/// <summary> /// <summary>
/// Gets the current data of the specified domain and DNS record /// Gets the current data of the specified domain and DNS record
/// </summary> /// </summary>
@ -71,8 +84,9 @@ namespace Iminetsoft
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest webreq = (HttpWebRequest)System.Net.WebRequest.Create(apiurl); HttpWebRequest webreq = (HttpWebRequest)System.Net.WebRequest.Create(apiurl);
webreq.Headers.Add("Authorization", $"sso-key {Key}:{Secret}"); webreq.Headers.Add("Authorization", $"sso-key {Key}:{Secret}");
webreq.Headers.Add("Content-Type", "application/json"); webreq.ContentType = "application/json";
webreq.Headers.Add("accept", "application/json"); webreq.Accept = "application/json";
webreq.UserAgent = UserAgent;
if (UpdateData == true && RecordToJson().Length > 0) if (UpdateData == true && RecordToJson().Length > 0)
{ {