Skip to content

Commit

Permalink
URL generation logic (avoid a lot of conflicts with AntiVrus heuristics)
Browse files Browse the repository at this point in the history
  • Loading branch information
XWolfOverride committed May 1, 2021
1 parent c83dafe commit e521687
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions DuckDNS/DDns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Update(List<string> messages)
}
else
{
string url = "https://www.duckdns.org/update?domains=" + Domain + "&token=" + Token + "&ip=&ipv6=";
string url = BuildURL(Domain, Token, "", "");//"https://www.duckdns.org/update?domains=" + Domain + "&token=" + Token + "&ip=&ipv6=";
string ret = Cli().DownloadString(url);
if (ret != "OK")
messages.Add("Failed");
Expand Down Expand Up @@ -82,7 +82,7 @@ private void UpdateDomain(DDnsDomain d, List<string> messages)
messages.Add(d.Domain + ": IP resolution failed");
return;
}
string url = "https://www.duckdns.org/update?domains=" + d.Domain + "&token=" + Token + "&ip=" + ipv4 + "&ipv6=" + ipv6;
string url = BuildURL(d.Domain, Token, ipv4, ipv6);// "https://www.duckdns.org/update?domains=" + d.Domain + "&token=" + Token + "&ip=" + ipv4 + "&ipv6=" + ipv6;
string ret;
if (!string.IsNullOrEmpty(d.BindIP))
{
Expand Down Expand Up @@ -110,6 +110,16 @@ private void UpdateDomain(DDnsDomain d, List<string> messages)
}
}

private string BuildURL(string domain, string token, string ipv4, string ipv6)
{
string url = ServiceURL;
url = url.Replace("<DOM>", domain);
url = url.Replace("<TKN>", token);
url = url.Replace("<IP4>", ipv4);
url = url.Replace("<IP6>", ipv6);
return url;
}

private void getHostIPs(string host, out string ipv4, out string ipv6)
{
ipv4 = null;
Expand Down Expand Up @@ -242,6 +252,7 @@ private string CharSwitch(string str)
public string Domain { get; set; }
public string Token { get; set; }
public string Interval { get; set; }
public string ServiceURL { get; set; } = "https://www.duckdns.org/update?domains=<DOM>&token=<TKN>&ip=<IP4>&ipv6=<IP6>";
public List<DDnsDomain> Domains { get; } = new List<DDnsDomain>();
}

Expand Down Expand Up @@ -339,6 +350,8 @@ private static void DeserializeInto(ref object o, Queue<string> data)
}
pname = pname.Trim();
PropertyInfo pi = t.GetProperty(pname);
if (pi == null)
continue;
if (array)
{
Type itemtype;
Expand Down

0 comments on commit e521687

Please sign in to comment.