From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 678D860449 for ; Wed, 14 Oct 2020 17:33:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5C71FB270 for ; Wed, 14 Oct 2020 17:33:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id EB6D5B267 for ; Wed, 14 Oct 2020 17:33:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B17EC45D59 for ; Wed, 14 Oct 2020 17:33:20 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Wed, 14 Oct 2020 17:33:15 +0200 Message-Id: <20201014153315.26964-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.136 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] applied: [PATCH] api: RPC environment: add client IP getter/setter to trait X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Oct 2020 15:33:21 -0000 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 --- 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; + + /// Set the client IP, should be re-set if a proxied connection was detected + fn set_client_ip(&mut self, _client_ip: Option) { + // dummy no-op implementation, as most environments don't need this + } + + /// Get the (real) client IP + fn get_client_ip(&self) -> Option { + None // dummy no-op implementation, as most environments don't need this + } } /// Environment Type -- 2.27.0