modules/wowlan: move options to "ipv4" attrset for future protocol expansion
This commit is contained in:
@@ -25,8 +25,8 @@
|
|||||||
sane.services.wg-home.ip = config.sane.hosts.by-name."moby".wg-home.ip;
|
sane.services.wg-home.ip = config.sane.hosts.by-name."moby".wg-home.ip;
|
||||||
sane.wowlan.enable = true;
|
sane.wowlan.enable = true;
|
||||||
sane.wowlan.patterns = [
|
sane.wowlan.patterns = [
|
||||||
{ destPort = 22; } # wake on SSH
|
{ ipv4.destPort = 22; } # wake on SSH
|
||||||
{ srcPort = 2587; } # wake on `ntfy-sh` push from servo
|
{ ipv4.srcPort = 2587; } # wake on `ntfy-sh` push from servo
|
||||||
];
|
];
|
||||||
|
|
||||||
# XXX colin: phosh doesn't work well with passwordless login,
|
# XXX colin: phosh doesn't work well with passwordless login,
|
||||||
|
@@ -25,7 +25,7 @@ let
|
|||||||
cfg = config.sane.wowlan;
|
cfg = config.sane.wowlan;
|
||||||
patternOpts = with lib; types.submodule {
|
patternOpts = with lib; types.submodule {
|
||||||
options = {
|
options = {
|
||||||
destPort = mkOption {
|
ipv4.destPort = mkOption {
|
||||||
type = types.nullOr types.port;
|
type = types.nullOr types.port;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
@@ -34,7 +34,7 @@ let
|
|||||||
(e.g. this machine made a long-running HTTP request, and the other side finally has data for us).
|
(e.g. this machine made a long-running HTTP request, and the other side finally has data for us).
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
srcPort = mkOption {
|
ipv4.srcPort = mkOption {
|
||||||
type = types.nullOr types.port;
|
type = types.nullOr types.port;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
@@ -59,12 +59,10 @@ let
|
|||||||
"0" + (lib.toHexString b)
|
"0" + (lib.toHexString b)
|
||||||
else
|
else
|
||||||
lib.toHexString b;
|
lib.toHexString b;
|
||||||
# formatPattern: patternOpts -> String
|
# formatIpv4Pattern: patternOpts.ipv4 -> String
|
||||||
# produces a string like this (example matches source port=0x0a1b):
|
# produces a string like this (example matches source port=0x0a1b):
|
||||||
# "-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:0a:1b:-:-"
|
# "-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:0a:1b:-:-"
|
||||||
#
|
formatIpv4Pattern = pat: let
|
||||||
# N.B.: the produced patterns match ONLY IPv4 -- not IPv6!
|
|
||||||
formatPattern = pat: let
|
|
||||||
destPortBytes = if pat.destPort != null then {
|
destPortBytes = if pat.destPort != null then {
|
||||||
high = pat.destPort / 256;
|
high = pat.destPort / 256;
|
||||||
low = lib.mod pat.destPort 256;
|
low = lib.mod pat.destPort 256;
|
||||||
@@ -139,7 +137,7 @@ in
|
|||||||
path = [ pkgs.iw pkgs.wirelesstools ];
|
path = [ pkgs.iw pkgs.wirelesstools ];
|
||||||
script = let
|
script = let
|
||||||
writePattern = pat: ''
|
writePattern = pat: ''
|
||||||
iwpriv wlan0 wow_set_pattern pattern=${formatPattern pat}
|
iwpriv wlan0 wow_set_pattern pattern=${formatIpv4Pattern pat.ipv4}
|
||||||
'';
|
'';
|
||||||
writePatterns = lib.concatStringsSep
|
writePatterns = lib.concatStringsSep
|
||||||
"\n"
|
"\n"
|
||||||
|
Reference in New Issue
Block a user