mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-10 09:18:15 +11:00
dns: Updated DNS record parsing and formatting
- Added support for new DNS record types - Improved formatting of update records in BatchForm.cs
This commit is contained in:
parent
74548a22e2
commit
5d59bdee64
@ -1,12 +1,10 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Principal;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.VisualBasic;
|
using System.Windows.Forms.VisualStyles;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using ContentAlignment = System.Drawing.ContentAlignment;
|
||||||
using Point = System.Drawing.Point;
|
using Point = System.Drawing.Point;
|
||||||
|
|
||||||
namespace FireWallet
|
namespace FireWallet
|
||||||
@ -620,7 +618,7 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
else if (b.method == "UPDATE")
|
else if (b.method == "UPDATE")
|
||||||
{
|
{
|
||||||
sw.WriteLine(b.domain + "," + b.method + ",[" + string.Join(", ", b.update.Select(record => record.ToString())) + "]");
|
sw.WriteLine(b.domain + "," + b.method + ",[" + string.Join(";", b.update.Select(record => record.ToString())) + "]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -652,14 +650,57 @@ namespace FireWallet
|
|||||||
{
|
{
|
||||||
if (split[1] == "UPDATE")
|
if (split[1] == "UPDATE")
|
||||||
{
|
{
|
||||||
// Select operation and import domains
|
// Join the rest of the line
|
||||||
string[] newDomains = new string[domains.Length + 1];
|
string[] updateArray = new string[split.Length - 2];
|
||||||
for (int i = 0; i < domains.Length; i++)
|
for (int i = 0; i < updateArray.Length; i++)
|
||||||
{
|
{
|
||||||
newDomains[i] = domains[i];
|
updateArray[i] = split[i + 2];
|
||||||
}
|
}
|
||||||
newDomains[domains.Length] = split[0];
|
string updateString = string.Join(",", updateArray);
|
||||||
domains = newDomains;
|
updateString.TrimStart('[');
|
||||||
|
updateString.TrimEnd(']');
|
||||||
|
|
||||||
|
string[] updateSplit = updateString.Split(';');
|
||||||
|
DNS[] UpdateRecords = new DNS[updateSplit.Length];
|
||||||
|
int r = 0;
|
||||||
|
foreach (string update in updateSplit)
|
||||||
|
{
|
||||||
|
string[] updateRecord = update.Split(',');
|
||||||
|
string type = updateRecord[0];
|
||||||
|
type = type.Split(':')[1];
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case "NS":
|
||||||
|
string ns = updateRecord[1].Split(':')[1].Replace("\"","");
|
||||||
|
UpdateRecords[r] = new DNS(type, ns);
|
||||||
|
break;
|
||||||
|
case "DS":
|
||||||
|
int keyTag = int.Parse(updateRecord[1].Split(':')[1]);
|
||||||
|
int algorithm = int.Parse(updateRecord[2].Split(':')[1]);
|
||||||
|
int digestType = int.Parse(updateRecord[3].Split(':')[1]);
|
||||||
|
string digest = updateRecord[4].Split(':')[1].Replace("\"", "");
|
||||||
|
|
||||||
|
UpdateRecords[r] = new DNS(type, keyTag, algorithm, digestType, digest);
|
||||||
|
break;
|
||||||
|
case "TXT":
|
||||||
|
string txt = updateRecord[1].Split(':')[1].Replace("\"", "");
|
||||||
|
txt.Replace("[", "");
|
||||||
|
txt.Replace("]", "");
|
||||||
|
UpdateRecords[r] = new DNS(type, new string[] { txt });
|
||||||
|
break;
|
||||||
|
case "GLUE4":
|
||||||
|
case "GLUE6":
|
||||||
|
string nsGlue = updateRecord[1].Split(':')[1].Replace("\"", "");
|
||||||
|
string address = updateRecord[2].Split(':')[1].Replace("\"", "");
|
||||||
|
UpdateRecords[r] = new DNS(type, nsGlue, address);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user