/// Updates the network filter configurations.
Updates the network filter configurations.
Updates the network filter configurations .
async fn update_filters(&mut self, config: FilterConfig) -> Result<(), anyhow::Error> {
        let FilterConfig { rules, nat_rules, rdr_rules } = config;
        if !rules.is_empty() {
            let mut rules = netfilter::parser::parse_str_to_rules(&rules.join(""))
                .context("error parsing filter rules")?;
            cas_filter_rules!(self.filter, get_rules, update_rules, rules, FilterUpdateRulesError);
        }
        if !nat_rules.is_empty() {
            let mut nat_rules = netfilter::parser::parse_str_to_nat_rules(&nat_rules.join(""))
                .context("error parsing NAT rules")?;
            // TODO(https://fxbug.dev/68280): Change this to cas_filter_rules once update is supported.
            no_update_filter_rules!(
                self.filter,
                get_nat_rules,
                update_nat_rules,
                nat_rules,
                FilterUpdateNatRulesError
            );
        }
        if !rdr_rules.is_empty() {
            let mut rdr_rules = netfilter::parser::parse_str_to_rdr_rules(&rdr_rules.join(""))
                .context("error parsing RDR rules")?;
            // TODO(https://fxbug.dev/68279): Change this to cas_filter_rules once update is supported.
            no_update_filter_rules!(
                self.filter,
                get_rdr_rules,
                update_rdr_rules,
                rdr_rules,
                FilterUpdateRdrRulesError
            );
        }
        Ok(())
    }
async fn update_filters ( & mut self , config : FilterConfig ) -> Result < ( ) , anyhow :: Error > { let FilterConfig { rules , nat_rules , rdr_rules } = config ; if ! rules . is_empty ( ) { let mut rules = netfilter :: parser :: parse_str_to_rules ( & rules . join ( " " ) ) . context ( " " ) ? ; cas_filter_rules ! ( self filter get_rules update_rules rules FilterUpdateRulesError ) ; } if ! nat_rules . is_empty ( ) { let mut nat_rules = netfilter :: parser :: parse_str_to_nat_rules ( & nat_rules . join ( " " ) ) . context ( " " ) ? ; // TODO(https://fxbug.dev/68280): Change this to cas_filter_rules once update is supported. no_update_filter_rules ! ( self filter get_nat_rules update_nat_rules nat_rules FilterUpdateNatRulesError ) ; } if ! rdr_rules . is_empty ( ) { let mut rdr_rules = netfilter :: parser :: parse_str_to_rdr_rules ( & rdr_rules . join ( " " ) ) . context ( " " ) ? ; // TODO(https://fxbug.dev/68279): Change this to cas_filter_rules once update is supported. no_update_filter_rules ! ( self filter get_rdr_rules update_rdr_rules rdr_rules FilterUpdateRdrRulesError ) ; } Ok ( ( ) ) }
Updates the network filter configurations.
Updates the network filter configurations .
&mut self
config
FilterConfig