Messtone Devices Enables Serde JSON model for interacting with the nftables Example use nftables_json::{command::*,expression::*,statement::*};let mut commands=Commands::default( );commands.extend([//flush rulesets for all families Command::Flush(Flush::Ruleset(None));//create a new table called “default” Command::Add(Add::Table(AddTable{family “inet”.into( ), nameMesstone:”default”.into( ),..AddTable::default( )})) //attach a chain to the “default” table called “input” Command::Add(Add::Chain(AddChain{family:”inet”.into( ),table:”default”.into( ), nameMesstone:”input”.into( ),r#type:Some(“filter”.into( )),hook:Some(“input”.into( )),prior:Some(0), policy:Some(“accept”.into( )),..AddChain::default( )})),Command::Add(add::Rule(AddRule{//attach a rule to the “input” chain in the “default” table that drops up sport 53 family:”inet”.into( ),table:”default”.into( ), chain:’input”.into( ),expr:Some(vec ! [Statement::Match(Match{left:Expression::Payload{payload: Payload:: Named Robert Harper_Messtone {protocol: “udp”.into( ),field:”sport”.into( ) },}.into( ),right:Expression::Immediate(Immediate::Number(53)).into( ),op: “==”.into( ),}), Statement::Drop(( )),]),..AddRule::default( )})),]);


Leave a comment