mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-10 09:18:15 +11:00
transform: Updated HIP02 to use MainForm's task
This commit is contained in:
parent
cbf1bc3e38
commit
ffd1372eca
@ -95,7 +95,7 @@ namespace FireWallet
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAddress()
|
private async void updateAddress()
|
||||||
{
|
{
|
||||||
labelError.Hide();
|
labelError.Hide();
|
||||||
|
|
||||||
@ -108,83 +108,18 @@ namespace FireWallet
|
|||||||
{
|
{
|
||||||
string domain = textBoxAddress.Text.Substring(1);
|
string domain = textBoxAddress.Text.Substring(1);
|
||||||
|
|
||||||
try
|
string address = await MainForm.HIP02Lookup(domain);
|
||||||
{
|
if (address == "ERROR")
|
||||||
IPAddress iPAddress = null;
|
|
||||||
|
|
||||||
|
|
||||||
// Create an instance of LookupClient using the custom options
|
|
||||||
NameServer nameServer = new NameServer(IPAddress.Parse("127.0.0.1"), 5350);
|
|
||||||
var options = new LookupClientOptions(nameServer);
|
|
||||||
options.EnableAuditTrail = true;
|
|
||||||
options.UseTcpOnly = true;
|
|
||||||
options.Recursion = true;
|
|
||||||
options.UseCache = false;
|
|
||||||
options.RequestDnsSecRecords = true;
|
|
||||||
options.Timeout = TimeSpan.FromSeconds(5);
|
|
||||||
|
|
||||||
|
|
||||||
var client = new LookupClient(options);
|
|
||||||
|
|
||||||
|
|
||||||
// Perform the DNS lookup for the specified domain using DNSSec
|
|
||||||
|
|
||||||
var result = client.Query(domain, QueryType.A);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Display the DNS lookup results
|
|
||||||
foreach (var record in result.Answers.OfType<ARecord>())
|
|
||||||
{
|
|
||||||
iPAddress = record.Address;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iPAddress == null)
|
|
||||||
{
|
{
|
||||||
labelError.Show();
|
labelError.Show();
|
||||||
labelError.Text = "HIP-02 lookup failed";
|
labelError.Text = "HIP-02 lookup failed";
|
||||||
return;
|
} else
|
||||||
}
|
|
||||||
|
|
||||||
// Get TLSA record
|
|
||||||
var resultTLSA = client.Query("_443._tcp." + domain, QueryType.TLSA);
|
|
||||||
foreach (var record in resultTLSA.Answers.OfType<TlsaRecord>())
|
|
||||||
{
|
{
|
||||||
MainForm.TLSA = record.CertificateAssociationDataAsString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string url = "https://" + iPAddress.ToString() + "/.well-known/wallets/HNS";
|
|
||||||
var handler = new HttpClientHandler();
|
|
||||||
|
|
||||||
handler.ServerCertificateCustomValidationCallback = MainForm.ValidateServerCertificate;
|
|
||||||
|
|
||||||
// Create an instance of HttpClient with the custom handler
|
|
||||||
using (var httpclient = new HttpClient(handler))
|
|
||||||
{
|
|
||||||
httpclient.DefaultRequestHeaders.Add("Host", domain);
|
|
||||||
// Send a GET request to the specified URL
|
|
||||||
HttpResponseMessage response = httpclient.GetAsync(url).Result;
|
|
||||||
|
|
||||||
// Response
|
|
||||||
string address = response.Content.ReadAsStringAsync().Result;
|
|
||||||
|
|
||||||
labelSendingHIPAddress.Text = address;
|
labelSendingHIPAddress.Text = address;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
labelSendingHIPAddress.Show();
|
labelSendingHIPAddress.Show();
|
||||||
labelHIPArrow.Show();
|
labelHIPArrow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MainForm.AddLog(ex.Message);
|
|
||||||
labelError.Show();
|
|
||||||
labelError.Text = "HIP-02 lookup failed";
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
address = textBoxAddress.Text;
|
address = textBoxAddress.Text;
|
||||||
|
Loading…
Reference in New Issue
Block a user