]> git.proxmox.com Git - pve-manager.git/commitdiff
node: wake-on-lan: document defaults and small style clean-up
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 28 Mar 2024 16:52:25 +0000 (17:52 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 28 Mar 2024 16:52:25 +0000 (17:52 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Nodes.pm
PVE/NodeConfig.pm

index 4f9640b2b5df2718e7c2d47e70583f469ebaae84..3bc17534630677120473009811dbb109a064c066 100644 (file)
@@ -699,7 +699,6 @@ __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;
@@ -714,9 +713,8 @@ __PACKAGE__->register_method({
        setsockopt($sock, Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1)
            || die "Unable to set socket option: $!\n";
 
-       if (defined($bind_iface)) {
-           # Null terminated interface name
-           my $bind_iface_raw = pack('Z*', $bind_iface);
+       if (defined(my $bind_iface = $local_wol_config->{'bind-interface'})) {
+           my $bind_iface_raw = pack('Z*', $bind_iface); # Null terminated interface name
            setsockopt($sock, Socket::SOL_SOCKET, Socket::SO_BINDTODEVICE, $bind_iface_raw)
                || die "Unable to bind socket to interface '$bind_iface': $!\n";
        }
index 5fa8001c99d513d2153478231c6c8ce991e76fbe..5f58dff5540b78d79a3642745ab87f6efbf4edca 100644 (file)
@@ -106,6 +106,7 @@ my $wakeonlan_desc = {
     'bind-interface' => {
        type => 'string',
        description => 'Bind to this interface when sending wake on LAN packet',
+       default => 'The interface carrying the default route',
        format => 'pve-iface',
        format_description => 'bind interface',
        optional => 1,
@@ -113,6 +114,7 @@ my $wakeonlan_desc = {
     'broadcast-address' => {
        type => 'string',
        description => 'IPv4 broadcast address to use when sending wake on LAN packet',
+       default => '255.255.255.255',
        format => 'ipv4',
        format_description => 'IPv4 broadcast address',
        optional => 1,