Compare commits
2 commits
d78cea8ca9
...
80bafc9f10
Author | SHA1 | Date | |
---|---|---|---|
Aode (Lion) | 80bafc9f10 | ||
Aode (Lion) | 72cf39b411 |
574
Cargo.lock
generated
574
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@ async-fs = "1.3.0"
|
|||
async-process = "1.0.0"
|
||||
async-trait = "0.1.40"
|
||||
base64 = "0.13.0"
|
||||
bcrypt = "0.9.0"
|
||||
bcrypt = "0.10.1"
|
||||
blocking = "1.0.0"
|
||||
config = { version = "0.11.0", features = ["toml"] }
|
||||
futures-lite = "1.8.0"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(clippy::needless_borrow)]
|
||||
|
||||
use blocking::unblock;
|
||||
use futures_lite::*;
|
||||
use once_cell::sync::Lazy;
|
||||
|
|
23
src/rules.rs
23
src/rules.rs
|
@ -69,7 +69,7 @@ pub(crate) async fn delete(db: &Db, rule_id: &str) -> Result<Rule, anyhow::Error
|
|||
|
||||
let rule = tree
|
||||
.remove(rule_id.as_bytes())?
|
||||
.ok_or(anyhow::anyhow!("No rule with id {}", rule_id))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("No rule with id {}", rule_id))?;
|
||||
|
||||
tree.flush_async().await?;
|
||||
|
||||
|
@ -147,17 +147,16 @@ async fn set_rule(
|
|||
{
|
||||
let has_nat_subnet = interfaces.nats.iter().any(|nat_iface| {
|
||||
*nat_iface == iface.interface
|
||||
|| *nat_iface != iface.interface
|
||||
&& interfaces
|
||||
.internal
|
||||
.iter()
|
||||
.chain(&interfaces.tunnel)
|
||||
.chain(&interfaces.vlan)
|
||||
.any(|other_iface| {
|
||||
*nat_iface == other_iface.interface
|
||||
&& other_iface.ip == iface.ip
|
||||
&& other_iface.mask == iface.mask
|
||||
})
|
||||
|| interfaces
|
||||
.internal
|
||||
.iter()
|
||||
.chain(&interfaces.tunnel)
|
||||
.chain(&interfaces.vlan)
|
||||
.any(|other_iface| {
|
||||
*nat_iface == other_iface.interface
|
||||
&& other_iface.ip == iface.ip
|
||||
&& other_iface.mask == iface.mask
|
||||
})
|
||||
});
|
||||
|
||||
if !has_nat_subnet {
|
||||
|
|
|
@ -125,18 +125,20 @@ impl Interfaces {
|
|||
|
||||
let external = parse_interface_info(&output, &config.interface.external)?
|
||||
.next()
|
||||
.ok_or(anyhow!(
|
||||
"Failed to parse IP for interface {}",
|
||||
config.interface.external,
|
||||
))?;
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"Failed to parse IP for interface {}",
|
||||
config.interface.external,
|
||||
)
|
||||
})?;
|
||||
|
||||
let mut internal = Vec::new();
|
||||
|
||||
for iface in &config.interface.internal {
|
||||
internal.extend(parse_interface_info(&output, &iface)?);
|
||||
internal.extend(parse_interface_info(&output, iface)?);
|
||||
}
|
||||
|
||||
if internal.len() == 0 {
|
||||
if internal.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"No internal interfaces found for {:?}",
|
||||
config.interface.internal
|
||||
|
@ -146,13 +148,13 @@ impl Interfaces {
|
|||
let mut vlan = Vec::new();
|
||||
|
||||
for iface in &config.interface.vlan {
|
||||
vlan.extend(parse_interface_info(&output, &iface)?);
|
||||
vlan.extend(parse_interface_info(&output, iface)?);
|
||||
}
|
||||
|
||||
let mut tunnel = Vec::new();
|
||||
|
||||
for iface in &config.interface.tunnel {
|
||||
tunnel.extend(parse_interface_info(&output, &iface)?);
|
||||
tunnel.extend(parse_interface_info(&output, iface)?);
|
||||
}
|
||||
|
||||
Ok(Interfaces {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::startup::Interfaces;
|
||||
|
||||
static UNIVERSE: &'static str = "0.0.0.0/0";
|
||||
static UNIVERSE: &str = "0.0.0.0/0";
|
||||
|
||||
pub(crate) fn firewall_rules(interfaces: &Interfaces) -> String {
|
||||
filter(interfaces) + "\n" + &nat(interfaces)
|
||||
|
|
Loading…
Reference in a new issue