@@ -13,9 +13,16 @@ namespace DuckDNS
13
13
class DDns
14
14
{
15
15
private const string FILENAME = "DuckDNS.cfg" ;
16
- private WebClient cli ;
16
+ private WebClient wclient ;
17
17
private string confPath ;
18
18
19
+ private WebClient Cli ( )
20
+ {
21
+ if ( wclient == null )
22
+ wclient = new WebClient ( ) ;
23
+ return wclient ;
24
+ }
25
+
19
26
/// <summary>
20
27
/// This method updates the Duck DNS Subdomain IP address.
21
28
/// </summary>
@@ -32,7 +39,7 @@ public void Update(List<string> messages)
32
39
else
33
40
{
34
41
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 ) ;
36
43
if ( ret != "OK" )
37
44
messages . Add ( "Failed" ) ;
38
45
}
@@ -65,7 +72,7 @@ private void UpdateDomain(DDnsDomain d, List<string> messages)
65
72
getHostIPs ( d . ResolutionValue , out ipv4 , out ipv6 ) ;
66
73
break ;
67
74
case DDnsResolutionMode . WebService :
68
- IPset ( cli . DownloadString ( d . ResolutionValue ) , out ipv4 , out ipv6 ) ;
75
+ IPset ( Cli ( ) . DownloadString ( d . ResolutionValue ) , out ipv4 , out ipv6 ) ;
69
76
break ;
70
77
default :
71
78
throw new Exception ( "Resolution mode not implemented" ) ;
@@ -92,9 +99,7 @@ private void UpdateDomain(DDnsDomain d, List<string> messages)
92
99
}
93
100
else
94
101
{
95
- if ( cli == null )
96
- cli = new WebClient ( ) ;
97
- ret = cli . DownloadString ( url ) ;
102
+ ret = Cli ( ) . DownloadString ( url ) ;
98
103
}
99
104
if ( ret != "OK" )
100
105
messages . Add ( d . Domain + ": Failed" ) ;
0 commit comments