/// <summary> /// Append extra options to an existing rule (via parsing) /// </summary> /// <param name="rule"></param> /// <param name="version"></param> /// <param name="chains"></param> /// <param name="createChain"></param> public void AppendToRule(String rule, int version, IpTablesChainSet chains = null, bool createChain = false) { Cow(); string[] arguments = ArgumentHelper.SplitArguments(rule); int count = arguments.Length; try { var parser = new RuleParser(arguments, this, chains, Chain.Table); //Parse the extra options bool not = false; for (int i = 0; i < count; i++) { if (arguments[i] == "!") { not = true; continue; } i += parser.FeedToSkip(i, not, version); not = false; } //Only replace the chain if a new one has been supplied if (parser.GetChainName() != null) { var chain = parser.GetChainFromSet(); if (chain == null) { if (!createChain) { throw new IpTablesNetException(String.Format("Unable to find chain: {0}", parser.ChainName)); } chain = parser.GetNewChain(_system, chain.IpVersion); } Chain = chain; } } catch (Exception ex) { throw new IpTablesParserException(rule, ex); } }