Skip to content

Commit c83dafe

Browse files
committed
Bugfix
1 parent 1f4370e commit c83dafe

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

DuckDNS/DDns.cs

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ namespace DuckDNS
1313
class DDns
1414
{
1515
private const string FILENAME = "DuckDNS.cfg";
16-
private WebClient cli;
16+
private WebClient wclient;
1717
private string confPath;
1818

19+
private WebClient Cli()
20+
{
21+
if (wclient == null)
22+
wclient = new WebClient();
23+
return wclient;
24+
}
25+
1926
/// <summary>
2027
/// This method updates the Duck DNS Subdomain IP address.
2128
/// </summary>
@@ -32,7 +39,7 @@ public void Update(List<string> messages)
3239
else
3340
{
3441
string url = "https://www.duckdns.org/update?domains=" + Domain + "&token=" + Token + "&ip=&ipv6=";
35-
string ret = cli.DownloadString(url);
42+
string ret = Cli().DownloadString(url);
3643
if (ret != "OK")
3744
messages.Add("Failed");
3845
}
@@ -65,7 +72,7 @@ private void UpdateDomain(DDnsDomain d, List<string> messages)
6572
getHostIPs(d.ResolutionValue, out ipv4, out ipv6);
6673
break;
6774
case DDnsResolutionMode.WebService:
68-
IPset(cli.DownloadString(d.ResolutionValue), out ipv4, out ipv6);
75+
IPset(Cli().DownloadString(d.ResolutionValue), out ipv4, out ipv6);
6976
break;
7077
default:
7178
throw new Exception("Resolution mode not implemented");
@@ -92,9 +99,7 @@ private void UpdateDomain(DDnsDomain d, List<string> messages)
9299
}
93100
else
94101
{
95-
if (cli == null)
96-
cli = new WebClient();
97-
ret = cli.DownloadString(url);
102+
ret = Cli().DownloadString(url);
98103
}
99104
if (ret != "OK")
100105
messages.Add(d.Domain + ": Failed");

0 commit comments

Comments
 (0)