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 A4D3FBBAFE for ; Tue, 26 Mar 2024 10:17:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 83BDE10F12 for ; Tue, 26 Mar 2024 10:17:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 for ; Tue, 26 Mar 2024 10:17:13 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B17204212B for ; Tue, 26 Mar 2024 10:17:13 +0100 (CET) From: Christian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 26 Mar 2024 10:16:58 +0100 Message-Id: <20240326091659.63483-4-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326091659.63483-1-c.ebner@proxmox.com> References: <20240326091659.63483-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.032 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [nodes.pm, nodeconfig.pm] Subject: [pve-devel] [PATCH v2 pve-manager 3/4] fix #5255: node: wol: configurable broadcast address X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2024 09:17:44 -0000 Allows to configure a custom broadcast address to use when sending a wake on lan packet to wake a remote node. Default behaviour remains to fallback to 255.255.255.255. Signed-off-by: Christian Ebner --- changes since version 1: - Adapted to use property string PVE/API2/Nodes.pm | 3 ++- PVE/NodeConfig.pm | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index 9ffe7494..4f9640b2 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -700,11 +700,12 @@ __PACKAGE__->register_method({ my $local_config = PVE::NodeConfig::load_config($local_node); my $local_wol_config = PVE::NodeConfig::get_wakeonlan_config($local_config); my $bind_iface = $local_wol_config->{'bind-interface'}; + my $broadcast_addr = $local_wol_config->{'broadcast-address'} // '255.255.255.255'; $mac_addr =~ s/://g; my $packet = chr(0xff) x 6 . pack('H*', $mac_addr) x 16; - my $addr = gethostbyname('255.255.255.255'); + my $addr = gethostbyname($broadcast_addr); my $port = getservbyname('discard', 'udp'); my $to = Socket::pack_sockaddr_in($port, $addr); diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm index ee316296..5fa8001c 100644 --- a/PVE/NodeConfig.pm +++ b/PVE/NodeConfig.pm @@ -110,6 +110,13 @@ my $wakeonlan_desc = { format_description => 'bind interface', optional => 1, }, + 'broadcast-address' => { + type => 'string', + description => 'IPv4 broadcast address to use when sending wake on LAN packet', + format => 'ipv4', + format_description => 'IPv4 broadcast address', + optional => 1, + }, }; $confdesc->{wakeonlan} = { -- 2.39.2