summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-07-03 14:55:16 +0200
committerLinus Färnstrand <linus@mullvad.net>2018-07-03 15:25:18 +0200
commit0359852bde5185fbbdf826ab6165d5c595f66914 (patch)
tree60ba16b6df839d9feceb2148735a9a879f394419
parent38968509b59329f2d0743312fc8f9a4f98daa66c (diff)
downloadmullvadvpn-0359852bde5185fbbdf826ab6165d5c595f66914.tar.xz
mullvadvpn-0359852bde5185fbbdf826ab6165d5c595f66914.zip
Don't store Table in Linux firewall to make it impl Send
-rw-r--r--talpid-core/src/firewall/linux/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/talpid-core/src/firewall/linux/mod.rs b/talpid-core/src/firewall/linux/mod.rs
index 25e38f99cc..67005516a3 100644
--- a/talpid-core/src/firewall/linux/mod.rs
+++ b/talpid-core/src/firewall/linux/mod.rs
@@ -74,7 +74,7 @@ enum End {
/// The Linux implementation for the `Firewall` trait.
pub struct Netfilter {
dns_settings: DnsSettings,
- table: Table,
+ table_name: CString,
}
impl Firewall for Netfilter {
@@ -83,7 +83,7 @@ impl Firewall for Netfilter {
fn new<P: AsRef<Path>>(_cache_dir: P) -> Result<Self> {
Ok(Netfilter {
dns_settings: DnsSettings::new()?,
- table: Table::new(&*TABLE_NAME, ProtoFamily::Inet)?,
+ table_name: TABLE_NAME.clone(),
})
}
@@ -92,7 +92,8 @@ impl Firewall for Netfilter {
self.dns_settings.set_dns(vec![tunnel.gateway.into()])?;
}
- let batch = PolicyBatch::new(&self.table)?.finalize(&policy)?;
+ let table = Table::new(&self.table_name, ProtoFamily::Inet)?;
+ let batch = PolicyBatch::new(&table)?.finalize(&policy)?;
self.send_and_process(&batch)
}
@@ -101,12 +102,13 @@ impl Firewall for Netfilter {
error!("Failed to reset DNS settings: {}", error.display_chain());
}
+ let table = Table::new(&self.table_name, ProtoFamily::Inet)?;
let batch = {
let mut batch = Batch::new()?;
// Our batch will add and remove the table even though the goal is just to remove it.
// This because only removing it throws a strange error if the table does not exist.
- batch.add(&self.table, nftnl::MsgType::Add)?;
- batch.add(&self.table, nftnl::MsgType::Del)?;
+ batch.add(&table, nftnl::MsgType::Add)?;
+ batch.add(&table, nftnl::MsgType::Del)?;
batch.finalize()?
};