/// <summary> /// Checks whether the specified traffic is allowed or denied. /// Returns the rule that determined the allow/deny outcome or null when no rule matched /// </summary> public GateAction CheckTraffic(ITraffic traffic, out Rule rule) { rule = null; if (!m_Enabled) { return(GateAction.Allow); } if (traffic == null) { return(GateAction.Deny); } var state = this[traffic.Direction]; var result = state.DefaultAction; Group fromGroup = null; Group toGroup = null; foreach (var rItem in state.Rules.OrderedValues) { if (rItem.Check(state, traffic, ref fromGroup, ref toGroup)) { result = rItem.Action; rule = rItem; break; } } return(result); }
/// <summary> /// Checks whether the specified traffic is allowed or denied /// </summary> public GateAction CheckTraffic(ITraffic traffic) { if (!m_Enabled) { return(GateAction.Allow); } Rule rule; return(this.CheckTraffic(traffic, out rule)); }
/// <summary> /// Cheks whether the rule is satisfied - all listed conditions are met. May lazily resolve addresses to groups /// </summary> public virtual bool Check(NetGate.State state, ITraffic traffic, ref Group fromGroup, ref Group toGroup) { if ( !Check_FromAddrs(traffic.FromAddress) || !Check_ToAddrs(traffic.ToAddress) || !Check_Methods(traffic.Method) || !Check_Services(traffic.Service) || !Check_URLFragments(traffic.RequestURL) ) { return(false); } if (m_FromGroups != null) { if (fromGroup == null) { fromGroup = state.FindGroupForAddress(traffic.FromAddress); } if (fromGroup == null) { return(false); } if (!Check_FromGroups(fromGroup.Name)) { return(false); } } if (m_ToGroups != null) { if (toGroup == null) { toGroup = state.FindGroupForAddress(traffic.ToAddress); } if (toGroup == null) { return(false); } if (!Check_ToGroups(toGroup.Name)) { return(false); } } if (m_FromExpression != null) { var netState = state.FindNetSiteStateForAddress(traffic.FromAddress, ref fromGroup); if (!invokeEvaluator(netState, m_FromExpression)) { return(false); } } if (m_ToExpression != null) { var netState = state.FindNetSiteStateForAddress(traffic.ToAddress, ref toGroup); if (!invokeEvaluator(netState, m_ToExpression)) { return(false); } } return(true); }
public GateAction CheckTraffic(ITraffic traffic) { return(GateAction.Allow); }
public GateAction CheckTraffic(ITraffic traffic, out Rule rule) { rule = null; return(GateAction.Allow); }
public GateAction CheckTraffic(ITraffic traffic, out Rule rule) { rule = null; return GateAction.Allow; }
public GateAction CheckTraffic(ITraffic traffic) { return GateAction.Allow; }
/// <summary> /// Checks whether the specified traffic is allowed or denied. /// Returns the rule that determined the allow/deny outcome or null when no rule matched /// </summary> public GateAction CheckTraffic(ITraffic traffic, out Rule rule) { rule = null; if (!m_Enabled) return GateAction.Allow; if (traffic==null) return GateAction.Deny; var state = this[traffic.Direction]; var result = state.DefaultAction; Group fromGroup = null; Group toGroup = null; foreach(var rItem in state.Rules.OrderedValues) { if (rItem.Check(state, traffic, ref fromGroup, ref toGroup)) { result = rItem.Action; rule = rItem; break; } } return result; }
/// <summary> /// Checks whether the specified traffic is allowed or denied /// </summary> public GateAction CheckTraffic(ITraffic traffic) { if (!m_Enabled) return GateAction.Allow; Rule rule; return this.CheckTraffic(traffic, out rule); }
/// <summary> /// Cheks whether the rule is satisfied - all listed conditions are met. May lazily resolve addresses to groups /// </summary> public virtual bool Check(NetGate.State state, ITraffic traffic, ref Group fromGroup, ref Group toGroup) { if ( !Check_FromAddrs(traffic.FromAddress) || !Check_ToAddrs(traffic.ToAddress) || !Check_Methods(traffic.Method) || !Check_Services(traffic.Service) || !Check_URLFragments(traffic.RequestURL) ) return false; if (m_FromGroups!=null) { if (fromGroup==null) fromGroup = state.FindGroupForAddress(traffic.FromAddress); if (fromGroup==null) return false; if (!Check_FromGroups(fromGroup.Name)) return false; } if (m_ToGroups!=null) { if (toGroup==null) toGroup = state.FindGroupForAddress(traffic.ToAddress); if (toGroup==null) return false; if (!Check_ToGroups(toGroup.Name)) return false; } if (m_FromExpression!=null) { var netState = state.FindNetSiteStateForAddress(traffic.FromAddress, ref fromGroup); if (!invokeEvaluator(netState, m_FromExpression)) return false; } if (m_ToExpression!=null) { var netState = state.FindNetSiteStateForAddress(traffic.ToAddress, ref toGroup); if (!invokeEvaluator(netState, m_ToExpression)) return false; } return true; }