From 691584c46e935cb18c0800807125815cda8b41f8 Mon Sep 17 00:00:00 2001 From: midefos Date: Wed, 14 Aug 2024 19:51:04 +0200 Subject: [PATCH] fixing position for docker --- src/iptables_wrapper.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/iptables_wrapper.rs b/src/iptables_wrapper.rs index 4293d8d..d7ffa7f 100644 --- a/src/iptables_wrapper.rs +++ b/src/iptables_wrapper.rs @@ -121,6 +121,13 @@ pub fn secure_port( return Err("Err gathering secure port rule".into()); } + let position = if docker && position.is_none() { + let all_docker_rules = iptables.list("filter", &chain).unwrap(); + Some(all_docker_rules.len() as i32 - 1) + } else { + position + }; + let rule = rule.unwrap(); if let Some(position) = position { insert_unique(&iptables, table, &chain, &rule, position)