fn to_action(&self, is_human: bool) -> Option<Action> {
        let mut action = Action::default();
        action.block_mode = action.atype.is_blocking();
        action.status = self.status;
        match &self.atype {
            SimpleActionT::Default => {}
            SimpleActionT::Monitor => action.atype = ActionType::Monitor,
            SimpleActionT::Ban(sub, _) => {
                action = sub.to_action(is_human).unwrap_or_default();
                action.ban = true;
            }
            SimpleActionT::RequestHeader(hdrs) => {
                action.headers = Some(hdrs.clone());
                action.atype = ActionType::AlterHeaders;
            }
            SimpleActionT::Response(content) => {
                action.atype = ActionType::Block;
                action.content = content.clone();
            }
            SimpleActionT::Challenge => {
                if !is_human {
                    return None;
                }
                action.atype = ActionType::Monitor;
            }
            SimpleActionT::Redirect(to) => {
                let mut headers = HashMap::new();
                action.content = "You are being redirected".into();
                headers.insert("Location".into(), to.clone());
                action.atype = ActionType::Block;
                action.headers = Some(headers);
            }
        }
        Some(action)
    }
/// returns None when it is a challenge, Some(action) otherwise
returns None when it is a challenge, Some(action) otherwise
returns None when it is a challenge Some ( action ) otherwise
fn to_action(&self, is_human: bool) -> Option<Action> {
        let mut action = Action::default();
        action.block_mode = action.atype.is_blocking();
        action.status = self.status;
        match &self.atype {
            SimpleActionT::Default => {}
            SimpleActionT::Monitor => action.atype = ActionType::Monitor,
            SimpleActionT::Ban(sub, _) => {
                action = sub.to_action(is_human).unwrap_or_default();
                action.ban = true;
            }
            SimpleActionT::RequestHeader(hdrs) => {
                action.headers = Some(hdrs.clone());
                action.atype = ActionType::AlterHeaders;
            }
            SimpleActionT::Response(content) => {
                action.atype = ActionType::Block;
                action.content = content.clone();
            }
            SimpleActionT::Challenge => {
                if !is_human {
                    return None;
                }
                action.atype = ActionType::Monitor;
            }
            SimpleActionT::Redirect(to) => {
                let mut headers = HashMap::new();
                action.content = "You are being redirected".into();
                headers.insert("Location".into(), to.clone());
                action.atype = ActionType::Block;
                action.headers = Some(headers);
            }
        }
        Some(action)
    }
fn to_action ( & self , is_human : bool ) -> Option < Action > { let mut action = Action :: default ( ) ; action . block_mode = action . atype . is_blocking ( ) ; action . status = self . status ; match & self . atype { SimpleActionT :: Default => { } SimpleActionT :: Monitor => action . atype = ActionType :: Monitor , SimpleActionT :: Ban ( sub , _ ) => { action = sub . to_action ( is_human ) . unwrap_or_default ( ) ; action . ban = true ; } SimpleActionT :: RequestHeader ( hdrs ) => { action . headers = Some ( hdrs . clone ( ) ) ; action . atype = ActionType :: AlterHeaders ; } SimpleActionT :: Response ( content ) => { action . atype = ActionType :: Block ; action . content = content . clone ( ) ; } SimpleActionT :: Challenge => { if ! is_human { return None ; } action . atype = ActionType :: Monitor ; } SimpleActionT :: Redirect ( to ) => { let mut headers = HashMap :: new ( ) ; action . content = " " . into ( ) ; headers . insert ( " " . into ( ) , to . clone ( ) ) ; action . atype = ActionType :: Block ; action . headers = Some ( headers ) ; } } Some ( action ) }
returns None when it is a challenge, Some(action) otherwise
returns None when it is a challenge Some ( action ) otherwise
&self
is_human
bool