public bool UpdateDomainFilter(DnsBlockList.Lists List, DomainFilter Filter) { List <byte[]> args = new List <byte[]>(); args.Add(PutStr(List)); args.Add(PutDomainFilter(Filter)); List <byte[]> ret = RemoteExec("UpdateDomainFilter", args); return(ret != null?GetBool(ret[0]) : false); }
public bool UpdateDomainFilter(DnsBlockList.Lists List, DomainFilter Filter) { Dictionary <string, Tuple <DomainFilter, Regex> > list = GetDomainFilterList(List); ListLock.EnterWriteLock(); Tuple <DomainFilter, Regex> KnownFilter; if (list.TryGetValue(Filter.Domain, out KnownFilter)) { KnownFilter.Item1.Enabled = Filter.Enabled; } else { AddDomainFilterImpl(List, Filter); } ListLock.ExitWriteLock(); return(true); }
private void LoadList(XmlNode rootNode, DnsBlockList.Lists List) { foreach (XmlNode node in rootNode) { if (node.Name != "DomainFilter") { continue; } DomainFilter domainFilter = new DomainFilter(); foreach (XmlNode subNode in node) { if (subNode.Name == "Domain") { domainFilter.Domain = subNode.InnerText; } else if (subNode.Name == "Enabled") { bool.TryParse(subNode.InnerText, out domainFilter.Enabled); } else if (subNode.Name == "Format") { Enum.TryParse(subNode.InnerText, out domainFilter.Format); } else if (subNode.Name == "HitCount") { int.TryParse(subNode.InnerText, out domainFilter.HitCount); } else if (subNode.Name == "LastHit") { DateTime dateTime; if (DateTime.TryParse(subNode.InnerText, out dateTime)) { domainFilter.LastHit = dateTime; } } } AddDomainFilterImpl(List, domainFilter); } }
private void StoreList(XmlWriter writer, DnsBlockList.Lists List) { Dictionary <string, Tuple <DomainFilter, Regex> > list = GetDomainFilterList(List); foreach (var item in list.Values) { DomainFilter domainfilter = item.Item1; writer.WriteStartElement("DomainFilter"); writer.WriteElementString("Domain", domainfilter.Domain); writer.WriteElementString("Enabled", domainfilter.Enabled.ToString()); writer.WriteElementString("Format", domainfilter.Format.ToString()); if (domainfilter.HitCount != 0) { writer.WriteElementString("HitCount", domainfilter.HitCount.ToString()); } if (domainfilter.LastHit != null) { writer.WriteElementString("LastHit", domainfilter.LastHit.ToString()); } writer.WriteEndElement(); } }
private bool AddDomainFilterImpl(DnsBlockList.Lists List, DomainFilter Filter) { // WARNING: ListLock must be locked for writing when entering this function. Dictionary <string, Tuple <DomainFilter, Regex> > list = GetDomainFilterList(List); try { Regex Matcher = null; if (Filter.Format == DomainFilter.Formats.RegExp) { Matcher = new Regex(Filter.Domain); } else if (Filter.Format == DomainFilter.Formats.WildCard) { Matcher = new Regex(Regex.Escape(Filter.Domain).Replace("\\*", ".*")); } list.Add(Filter.Domain, Tuple.Create(Filter, Matcher)); return(true); } catch { return(false); } }
public bool UpdateDomainFilter(DnsBlockList.Lists List, DomainFilter Filter) { return(RemoteExec("UpdateDomainFilter", new object[2] { List, Filter }, false)); }
protected byte[] PutDomainFilter(DomainFilter filter) { return(PutXmlObj(filter)); }