mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-10 09:18:15 +11:00
main: Moved HIP02 lookup to its own task
This commit is contained in:
parent
843f824b2f
commit
cbf1bc3e38
@ -1639,17 +1639,8 @@ namespace FireWallet
|
||||
|
||||
// Store TLSA hash
|
||||
public string TLSA { get; set; }
|
||||
private async void textBoxSendingTo_Leave(object sender, EventArgs e)
|
||||
public async Task<string> HIP02Lookup(string domain)
|
||||
{
|
||||
|
||||
labelSendingError.Hide();
|
||||
labelHIPArrow.Hide();
|
||||
labelSendingHIPAddress.Hide();
|
||||
if (textBoxSendingTo.Text == "") return;
|
||||
if (textBoxSendingTo.Text.Substring(0, 1) == "@")
|
||||
{
|
||||
string domain = textBoxSendingTo.Text.Substring(1);
|
||||
|
||||
try
|
||||
{
|
||||
IPAddress iPAddress = null;
|
||||
@ -1659,7 +1650,6 @@ namespace FireWallet
|
||||
// Create an instance of LookupClient using the custom options
|
||||
string ip = "127.0.0.1";
|
||||
int port = 5350;
|
||||
|
||||
if (UserSettings.ContainsKey("hip-02-ip"))
|
||||
{
|
||||
ip = UserSettings["hip-02-ip"];
|
||||
@ -1684,8 +1674,7 @@ namespace FireWallet
|
||||
options.Recursion = true;
|
||||
options.UseCache = false;
|
||||
options.RequestDnsSecRecords = true;
|
||||
options.Timeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
options.Timeout = httpClient.Timeout;
|
||||
var client = new LookupClient(options);
|
||||
|
||||
// Perform the DNS lookup for the specified domain using DNSSec
|
||||
@ -1701,7 +1690,7 @@ namespace FireWallet
|
||||
labelSendingError.Show();
|
||||
labelSendingError.Text = "HIP-02 lookup failed";
|
||||
AddLog("No IP found");
|
||||
return;
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
// Get TLSA record
|
||||
@ -1731,7 +1720,7 @@ namespace FireWallet
|
||||
labelSendingError.Text = "HIP-02 lookup failed";
|
||||
AddLog("HTTPS get failed");
|
||||
AddLog(response.Content.ReadAsStringAsync().Result);
|
||||
return;
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
// Response
|
||||
@ -1741,29 +1730,46 @@ namespace FireWallet
|
||||
|
||||
if (await ValidAddress(address))
|
||||
{
|
||||
labelSendingHIPAddress.Text = address;
|
||||
labelSendingHIPAddress.Show();
|
||||
labelHIPArrow.Show();
|
||||
return address;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelSendingError.Show();
|
||||
labelSendingError.Text = "Invalid Address";
|
||||
AddLog("Invalid Address\n" + address);
|
||||
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("HIP-02 lookup error");
|
||||
AddLog(ex.Message);
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
private async void textBoxSendingTo_Leave(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
labelSendingError.Hide();
|
||||
labelHIPArrow.Hide();
|
||||
labelSendingHIPAddress.Hide();
|
||||
if (textBoxSendingTo.Text == "") return;
|
||||
if (textBoxSendingTo.Text.Substring(0, 1) == "@")
|
||||
{
|
||||
string domain = textBoxSendingTo.Text.Substring(1);
|
||||
string address = await HIP02Lookup(domain);
|
||||
if (address == "ERROR")
|
||||
{
|
||||
labelSendingError.Show();
|
||||
labelSendingError.Text = "HIP-02 lookup failed";
|
||||
} else
|
||||
{
|
||||
labelSendingHIPAddress.Text = address;
|
||||
labelSendingHIPAddress.Show();
|
||||
labelHIPArrow.Show();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user