1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
// Copyright Pit Kleyersburg <pitkley@googlemail.com> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified or distributed // except according to those terms. //! # DFW - Docker Firewall Framework in Rust //! //! For detailed introductions, see the [README][github-readme]. //! //! [github-readme]: https://github.com/pitkley/dfw#readme //! //! ## License //! //! DFW is licensed under either of //! //! * Apache License, Version 2.0, (<http://www.apache.org/licenses/LICENSE-2.0>) //! * MIT license (<https://opensource.org/licenses/MIT>) //! //! at your option. // Increase the compiler's recursion limit for the `error_chain` crate. #![recursion_limit = "1024"] #![deny(missing_docs)] // declare modules mod de; pub mod errors; pub mod iptables; pub mod nftables; pub mod process; pub mod types; pub mod util; use errors::Result; use process::{Process, ProcessContext}; use serde::de::DeserializeOwned; use std::fmt::Debug; use types::DFW; /// This trait is used to distinguish between different firewall backends. /// /// To add a new firewall-backend create an empty struct implementing this trait. pub trait FirewallBackend: Sized where DFW<Self>: Process<Self>, { /// Associated type identifying the rule-type returned. type Rule; /// Associated type representing the firewall backend defaults/configuration. type Defaults: Debug + DeserializeOwned; /// Apply the processed rules. fn apply(rules: Vec<Self::Rule>, ctx: &ProcessContext<Self>) -> Result<()>; }