all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-firewall v2 3/3] proxmox-firewall: add localnet subcommand
Date: Tue, 27 May 2025 15:57:59 +0200	[thread overview]
Message-ID: <20250527135800.190084-4-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250527135800.190084-1-s.hanreich@proxmox.com>

pve-firewall provided the localnet subcommand to query the currently
used IPs in the management ipset. Reimplement this command in
proxmox-firewall to enable easier debugging.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-firewall/src/bin/proxmox-firewall.rs | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/proxmox-firewall/src/bin/proxmox-firewall.rs b/proxmox-firewall/src/bin/proxmox-firewall.rs
index f7e9516..d9409b2 100644
--- a/proxmox-firewall/src/bin/proxmox-firewall.rs
+++ b/proxmox-firewall/src/bin/proxmox-firewall.rs
@@ -10,6 +10,7 @@ use proxmox_firewall::firewall::Firewall;
 use proxmox_log as log;
 use proxmox_log::{LevelFilter, Logger};
 use proxmox_nftables::{client::NftError, NftClient};
+use proxmox_ve_config::firewall::host::Config as HostConfig;
 
 const HELP: &str = r#"
 USAGE:
@@ -20,6 +21,7 @@ COMMANDS:
   skeleton          Prints the firewall rule skeleton as accepted by 'nft -f -'
   compile           Compile and print firewall rules as accepted by 'nft -j -f -'
   start             Execute proxmox-firewall service in foreground
+  localnet          Print the contents of the management ipset
 "#;
 
 const RULE_BASE: &str = include_str!("../../resources/proxmox-firewall.nft");
@@ -122,6 +124,7 @@ pub enum Command {
     Help,
     Skeleton,
     Start,
+    Localnet,
 }
 
 impl std::str::FromStr for Command {
@@ -133,6 +136,7 @@ impl std::str::FromStr for Command {
             "compile" => Command::Compile,
             "skeleton" => Command::Skeleton,
             "start" => Command::Start,
+            "localnet" => Command::Localnet,
             cmd => {
                 bail!("{cmd} is not a valid command")
             }
@@ -157,6 +161,14 @@ fn run_command(command: Command) -> Result<(), Error> {
             println!("{}", RULE_BASE);
         }
         Command::Start => run_firewall()?,
+        Command::Localnet => {
+            let management_ips = HostConfig::management_ips()?;
+
+            println!("Management IPSet:");
+            for ip in management_ips {
+                println!("{ip}");
+            }
+        }
     };
 
     Ok(())
-- 
2.39.5


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-05-27 13:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27 13:57 [pve-devel] [PATCH docs/proxmox-firewall v2 0/4] migrate proxmox-firewall to proxmox-log + introduce subcommands Stefan Hanreich
2025-05-27 13:57 ` [pve-devel] [PATCH proxmox-firewall v2 1/3] firewall: use proxmox_log Stefan Hanreich
2025-05-27 13:57 ` [pve-devel] [PATCH proxmox-firewall v2 2/3] proxmox-firewall: add subcommands Stefan Hanreich
2025-05-27 13:57 ` Stefan Hanreich [this message]
2025-05-27 13:58 ` [pve-devel] [PATCH pve-docs v2 1/1] firewall: update 'useful commands' section with new subcommands Stefan Hanreich
2025-07-24 15:09 ` [pve-devel] [PATCH docs/proxmox-firewall v2 0/4] migrate proxmox-firewall to proxmox-log + introduce subcommands Stefan Hanreich
2025-07-29  6:21 ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250527135800.190084-4-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal