public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH] api: RPC environment: add client IP getter/setter to trait
Date: Wed, 14 Oct 2020 17:33:15 +0200	[thread overview]
Message-ID: <20201014153315.26964-1-t.lamprecht@proxmox.com> (raw)

This is similar to what we have in PVE and PMG now. Will be used to
set the real client IP for proxied connections.

with a dummy implementation, which avoids the need to implement it
for the CLI or Backup environments, which do not have or care for a
client IP

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---

preparatory to a proxmox-backup patch set I'm working on

 proxmox/src/api/rpc_environment.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/proxmox/src/api/rpc_environment.rs b/proxmox/src/api/rpc_environment.rs
index 1b68928..430f3a6 100644
--- a/proxmox/src/api/rpc_environment.rs
+++ b/proxmox/src/api/rpc_environment.rs
@@ -19,6 +19,16 @@ pub trait RpcEnvironment: std::any::Any + AsAny + Send {
 
     /// Get user name
     fn get_user(&self) -> Option<String>;
+
+    /// Set the client IP, should be re-set if a proxied connection was detected
+    fn set_client_ip(&mut self, _client_ip: Option<std::net::SocketAddr>) {
+        // dummy no-op implementation, as most environments don't need this
+    }
+
+    /// Get the (real) client IP
+    fn get_client_ip(&self) -> Option<std::net::SocketAddr> {
+        None // dummy no-op implementation, as most environments don't need this
+    }
 }
 
 /// Environment Type
-- 
2.27.0





                 reply	other threads:[~2020-10-14 15:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201014153315.26964-1-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pbs-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal