mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-24 08:08:14 +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
|
// Store TLSA hash
|
||||||
public string TLSA { get; set; }
|
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
|
try
|
||||||
{
|
{
|
||||||
IPAddress iPAddress = null;
|
IPAddress iPAddress = null;
|
||||||
@ -1659,7 +1650,6 @@ namespace FireWallet
|
|||||||
// Create an instance of LookupClient using the custom options
|
// Create an instance of LookupClient using the custom options
|
||||||
string ip = "127.0.0.1";
|
string ip = "127.0.0.1";
|
||||||
int port = 5350;
|
int port = 5350;
|
||||||
|
|
||||||
if (UserSettings.ContainsKey("hip-02-ip"))
|
if (UserSettings.ContainsKey("hip-02-ip"))
|
||||||
{
|
{
|
||||||
ip = UserSettings["hip-02-ip"];
|
ip = UserSettings["hip-02-ip"];
|
||||||
@ -1684,8 +1674,7 @@ namespace FireWallet
|
|||||||
options.Recursion = true;
|
options.Recursion = true;
|
||||||
options.UseCache = false;
|
options.UseCache = false;
|
||||||
options.RequestDnsSecRecords = true;
|
options.RequestDnsSecRecords = true;
|
||||||
options.Timeout = TimeSpan.FromSeconds(5);
|
options.Timeout = httpClient.Timeout;
|
||||||
|
|
||||||
var client = new LookupClient(options);
|
var client = new LookupClient(options);
|
||||||
|
|
||||||
// Perform the DNS lookup for the specified domain using DNSSec
|
// Perform the DNS lookup for the specified domain using DNSSec
|
||||||
@ -1701,7 +1690,7 @@ namespace FireWallet
|
|||||||
labelSendingError.Show();
|
labelSendingError.Show();
|
||||||
labelSendingError.Text = "HIP-02 lookup failed";
|
labelSendingError.Text = "HIP-02 lookup failed";
|
||||||
AddLog("No IP found");
|
AddLog("No IP found");
|
||||||
return;
|
return "ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get TLSA record
|
// Get TLSA record
|
||||||
@ -1731,7 +1720,7 @@ namespace FireWallet
|
|||||||
labelSendingError.Text = "HIP-02 lookup failed";
|
labelSendingError.Text = "HIP-02 lookup failed";
|
||||||
AddLog("HTTPS get failed");
|
AddLog("HTTPS get failed");
|
||||||
AddLog(response.Content.ReadAsStringAsync().Result);
|
AddLog(response.Content.ReadAsStringAsync().Result);
|
||||||
return;
|
return "ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
@ -1741,29 +1730,46 @@ namespace FireWallet
|
|||||||
|
|
||||||
if (await ValidAddress(address))
|
if (await ValidAddress(address))
|
||||||
{
|
{
|
||||||
labelSendingHIPAddress.Text = address;
|
return address;
|
||||||
labelSendingHIPAddress.Show();
|
|
||||||
labelHIPArrow.Show();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labelSendingError.Show();
|
|
||||||
labelSendingError.Text = "Invalid Address";
|
|
||||||
AddLog("Invalid Address\n" + address);
|
AddLog("Invalid Address\n" + address);
|
||||||
|
return "ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddLog("HIP-02 lookup error");
|
AddLog("HIP-02 lookup error");
|
||||||
AddLog(ex.Message);
|
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.Show();
|
||||||
labelSendingError.Text = "HIP-02 lookup failed";
|
labelSendingError.Text = "HIP-02 lookup failed";
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
labelSendingHIPAddress.Text = address;
|
||||||
|
labelSendingHIPAddress.Show();
|
||||||
|
labelHIPArrow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user