-
Notifications
You must be signed in to change notification settings - Fork 38
More flexible defaults #19
Copy link
Copy link
Open
Description
For me the main missing convenience (beside issue #12) is the ability to change the default target IP (I often use wakeonlan from my home router where I want to send the packet to the local "lan" network and not to the "wan" side).
I use the following patch for now, which adds two features:
- Read
~/.wakeonlanwhen it exists (and when-fwas not specified). - Allow the special
*hwaddr in those files to mean that the specified IP (and port) is to be used by default.
diff --git a/wakeonlan b/wakeonlan
index 1d85f93..b7c8475 100755
--- a/wakeonlan
+++ b/wakeonlan
@@ -121,12 +121,6 @@ sub loadFromFile {
chomp;
($hwaddr, $ipaddr, $port) = split;
- if (! isValidHardwareAddress($hwaddr) ) {
- warn "Invalid hardware address: $hwaddr\n";
- $stats{invalid}++;
- next;
- }
-
$ipaddr = $DEFAULT_IP unless defined($ipaddr);
if (! isValidIPAddress($ipaddr) ) {
warn "Invalid IP address: $ipaddr\n";
@@ -141,6 +135,17 @@ sub loadFromFile {
next;
}
+ if ($hwaddr eq "*") {
+ warn "Using default IP $ipaddr";
+ $DEFAULT_IP = $ipaddr;
+ $DEFAULT_PORT = $port;
+ next;
+ } elsif (! isValidHardwareAddress($hwaddr) ) {
+ warn "Invalid hardware address: $hwaddr\n";
+ $stats{invalid}++;
+ next;
+ }
+
$stats{valid}++;
push @queue, [ $hwaddr, $ipaddr, $port ];
}
@@ -262,6 +267,8 @@ if (!$filename and !@ARGV) { pod2usage( -exitval => 0, -ver\
bose => 1); };
#
loadFromCommandLine(@ARGV);
+
+$filename = "$ENV{HOME}/.wakeonlan" if (!$filename && -e "$ENV{HOME}/.wakeonla\
n");
loadFromFile($filename) if $filename;
# print Dumper(@queue); Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels