Skip to content

Commit 4160f64

Browse files
committed
Try different way to empty the element
1 parent 8d6858b commit 4160f64

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

IPBanCore/Linux/IPBanLinuxFirewallD.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,8 @@ private bool CreateOrUpdateRule(bool drop, int priority, string ruleIP4, string
322322
{
323323
// go from source to rule element
324324
ruleElement4 = ruleElement4.ParentNode as XmlElement;
325-
foreach (var oldChild in ruleElement4.ChildNodes)
326-
{
327-
if (oldChild is XmlElement childElement)
328-
{
329-
ruleElement4.RemoveChild(childElement);
330-
}
331-
}
325+
ruleElement4.IsEmpty = true;
326+
ruleElement4.IsEmpty = false;
332327
}
333328
if (doc.SelectSingleNode($"//rule/source[@ipset='{ruleIP6}']") is not XmlElement ruleElement6)
334329
{
@@ -339,13 +334,8 @@ private bool CreateOrUpdateRule(bool drop, int priority, string ruleIP4, string
339334
{
340335
// go from source to rule element
341336
ruleElement6 = ruleElement6.ParentNode as XmlElement;
342-
foreach (var oldChild in ruleElement6.ChildNodes)
343-
{
344-
if (oldChild is XmlElement childElement)
345-
{
346-
ruleElement6.RemoveChild(childElement);
347-
}
348-
}
337+
ruleElement6.IsEmpty = true;
338+
ruleElement6.IsEmpty = false;
349339
}
350340

351341
// assign rule attributes

0 commit comments

Comments
 (0)