private String extractor(IpTablesRule arg) { String addr = arg.GetModule <CoreModule>("core").InInterface.Value; arg.GetModule <CoreModule>("core").InInterface = new ValueOrNot <String>(); return(addr); }
private IPAddress extractor(IpTablesRule arg) { IPAddress addr = arg.GetModule <CoreModule>("core").Source.Value.Address; arg.GetModule <CoreModule>("core").Source = new ValueOrNot <IpCidr>(); return(addr); }
public static bool Comparer(IpTablesRule rule1, IpTablesRule rule2) { var comment1 = rule1.GetModule<CommentModule>("comment"); var comment2 = rule2.GetModule<CommentModule>("comment"); if (comment1 == null || comment2 == null) return false; return comment1.CommentText == comment2.CommentText; }
/// <summary> /// Comparison that detirmines equality based on comment text /// </summary> /// <param name="rule1"></param> /// <param name="rule2"></param> /// <returns></returns> static bool CommentComparer(IpTablesRule rule1, IpTablesRule rule2) { var comment1 = rule1.GetModule <CommentModule>("comment"); var comment2 = rule2.GetModule <CommentModule>("comment"); if (comment1 == null || comment2 == null) { return(false); } return(comment1.CommentText == comment2.CommentText); }
/// <summary> /// Extract the first port (or range) from a IPTables rule. /// /// Supports both TCP & UDP protocol modules and Multiport /// </summary> /// <param name="rule"></param> /// <param name="source"></param> /// <returns></returns> public static PortOrRange ExtractPort(IpTablesRule rule, bool source) { var core = rule.GetModule <CoreModule>("core"); if (core == null || core.Protocol.Null || core.Protocol.Not) { return(new PortOrRange(0)); } var protocol = core.Protocol.Value.ToLower(); if (protocol == "tcp") { var pmod = rule.GetModule <TcpModule>("tcp"); if (pmod == null) { return(new PortOrRange(0)); } if (source) { return(pmod.SourcePort.Value); } return(pmod.DestinationPort.Value); } if (protocol == "udp") { var pmod = rule.GetModule <UdpModule>("udp"); if (pmod == null) { return(new PortOrRange(0)); } if (source) { return(pmod.SourcePort.Value); } return(pmod.DestinationPort.Value); } return(new PortOrRange(0)); }
public static void SourcePortSetter(IpTablesRule rule, List <PortOrRange> ranges) { var protocol = rule.GetModule <CoreModule>("core").Protocol; if (ranges.Count == 1 && !protocol.Null && !protocol.Not) { if (protocol.Value == "tcp") { var tcp = rule.GetModuleOrLoad <TcpModule>("tcp"); tcp.SourcePort = new ValueOrNot <PortOrRange>(ranges[0]); } else { var tcp = rule.GetModuleOrLoad <UdpModule>("udp"); tcp.SourcePort = new ValueOrNot <PortOrRange>(ranges[0]); } } else { var multiport = rule.GetModuleOrLoad <MultiportModule>("multiport"); multiport.SourcePorts = new ValueOrNot <IEnumerable <PortOrRange> >(ranges); } }
public static void SourcePortSetter(IpTablesRule rule, List<PortOrRange> ranges) { var protocol = rule.GetModule<CoreModule>("core").Protocol; if (ranges.Count == 1 && !protocol.Null && !protocol.Not) { if (protocol.Value == "tcp") { var tcp = rule.GetModuleOrLoad<TcpModule>("tcp"); tcp.SourcePort = new ValueOrNot<PortOrRange>(ranges[0]); } else { var tcp = rule.GetModuleOrLoad<UdpModule>("udp"); tcp.SourcePort = new ValueOrNot<PortOrRange>(ranges[0]); } } else { var multiport = rule.GetModuleOrLoad<MultiportModule>("multiport"); multiport.SourcePorts = new ValueOrNot<IEnumerable<PortOrRange>>(ranges); } }
private IPAddress extractSrcIp(IpTablesRule arg) { return(arg.GetModule <CoreModule>("core").Source.Value.Address); }
private PortOrRange extractSrcPort(IpTablesRule arg) { return(arg.GetModule <UdpModule>("udp").SourcePort.Value); }
private IPAddress extractor(IpTablesRule arg) { IPAddress addr = arg.GetModule<CoreModule>("core").Source.Value.Address; arg.GetModule<CoreModule>("core").Source = new ValueOrNot<IpCidr>(); return addr; }
private IPAddress extractSrcIp(IpTablesRule arg) { return arg.GetModule<CoreModule>("core").Source.Value.Address; }
private PortOrRange extractSrcPort(IpTablesRule arg) { return arg.GetModule<UdpModule>("udp").SourcePort.Value; }
private String extractor(IpTablesRule arg) { String addr = arg.GetModule<CoreModule>("core").InInterface.Value; arg.GetModule<CoreModule>("core").InInterface = new ValueOrNot<String>(); return addr; }