refactor: remove duplication
This commit is contained in:
109 files changed
+2206
-3078
No files matched your search
@@ -19,7 +19,6 @@
|
||||
./tg-ws-proxy.nix
|
||||
./geodata.nix
|
||||
./gui.nix
|
||||
./tray.nix
|
||||
./tui.nix
|
||||
./user-control.nix
|
||||
./host.nix
|
||||
|
||||
@@ -9,12 +9,7 @@ let
|
||||
types
|
||||
;
|
||||
t = import ./types.nix { inherit lib; };
|
||||
bool =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.bool;
|
||||
inherit default description;
|
||||
};
|
||||
inherit (import ./lib.nix { inherit lib; }) bool;
|
||||
in
|
||||
{
|
||||
options.services.proxy-suite.inbounds = {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# The option shapes this module declares over and over, in one place.
|
||||
{ lib }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
list =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
inherit description example;
|
||||
};
|
||||
nullStr =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
inherit description example;
|
||||
};
|
||||
bool =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.bool;
|
||||
inherit default description;
|
||||
};
|
||||
int =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.int;
|
||||
inherit default description;
|
||||
};
|
||||
positiveInt =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.ints.positive;
|
||||
inherit default description;
|
||||
};
|
||||
# An option path under services.proxy-suite, for the compatibility modules.
|
||||
path =
|
||||
path:
|
||||
[
|
||||
"services"
|
||||
"proxy-suite"
|
||||
]
|
||||
++ lib.splitString "." path;
|
||||
}
|
||||
@@ -3,12 +3,7 @@
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
t = import ./types.nix { inherit lib; };
|
||||
int =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.int;
|
||||
inherit default description;
|
||||
};
|
||||
inherit (import ./lib.nix { inherit lib; }) int;
|
||||
localSubnets =
|
||||
description:
|
||||
mkOption {
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
t = import ./types.nix { inherit lib; };
|
||||
list =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
inherit description example;
|
||||
};
|
||||
inherit (import ./lib.nix { inherit lib; }) list;
|
||||
in
|
||||
{
|
||||
options.services.proxy-suite.proxy.routing = {
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
p =
|
||||
path:
|
||||
[
|
||||
"services"
|
||||
"proxy-suite"
|
||||
]
|
||||
++ lib.splitString "." path;
|
||||
p = (import ./lib.nix { inherit lib; }).path;
|
||||
rm = path: replacement: lib.mkRemovedOptionModule (p path) replacement;
|
||||
# Top-level zapret options that moved under the engine namespace; the value is
|
||||
# the leaf name they carry there.
|
||||
@@ -24,6 +18,11 @@ let
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# The tray indicator became Proxy Suite GUI, which has the tray icon built in.
|
||||
(lib.mkRenamedOptionModule (p "tray.enable") (p "gui.enable"))
|
||||
(lib.mkRenamedOptionModule (p "tray.autostart") (p "gui.autostart"))
|
||||
(lib.mkRenamedOptionModule (p "tray.pollInterval") (p "gui.refreshInterval"))
|
||||
|
||||
# These were aliases; they are removal notices now, so there is one
|
||||
# compatibility policy instead of two.
|
||||
(rm "proxyInbounds" "Use services.proxy-suite.inbounds.")
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
token = types.nullOr (types.strMatching "[^[:space:]]+");
|
||||
path =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
inherit description example;
|
||||
};
|
||||
path = (import ./lib.nix { inherit lib; }).nullStr;
|
||||
in
|
||||
{
|
||||
options.services.proxy-suite.sshProxy = {
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
domains =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
inherit description example;
|
||||
};
|
||||
domains = (import ./lib.nix { inherit lib; }).list;
|
||||
in
|
||||
{
|
||||
options.services.proxy-suite.tgWsProxy = {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
p =
|
||||
path:
|
||||
[
|
||||
"services"
|
||||
"proxy-suite"
|
||||
]
|
||||
++ lib.splitString "." path;
|
||||
in
|
||||
{
|
||||
# The tray indicator became Proxy Suite GUI, which has the tray icon built in.
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule (p "tray.enable") (p "gui.enable"))
|
||||
(lib.mkRenamedOptionModule (p "tray.autostart") (p "gui.autostart"))
|
||||
(lib.mkRenamedOptionModule (p "tray.pollInterval") (p "gui.refreshInterval"))
|
||||
];
|
||||
}
|
||||
@@ -2,14 +2,7 @@
|
||||
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
list =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
inherit description example;
|
||||
};
|
||||
inherit (import ./lib.nix { inherit lib; }) list;
|
||||
|
||||
routingFields = {
|
||||
domains = list "Domain suffixes to match." [ "youtube.com" ];
|
||||
|
||||
@@ -54,139 +54,50 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
obfuscationType = types.submodule {
|
||||
options = {
|
||||
jc = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Junk packet count (Jc).";
|
||||
};
|
||||
jmin = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Minimum junk packet size (Jmin).";
|
||||
};
|
||||
jmax = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Maximum junk packet size (Jmax).";
|
||||
};
|
||||
s1 = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Handshake-init padding (S1).";
|
||||
};
|
||||
s2 = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Handshake-response padding (S2).";
|
||||
};
|
||||
s3 = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Cookie-reply padding (S3).";
|
||||
};
|
||||
s4 = mkOption {
|
||||
type = optionalUnsigned;
|
||||
default = null;
|
||||
description = "Transport-message padding (S4).";
|
||||
};
|
||||
h1 = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "Handshake-init header or range (H1).";
|
||||
};
|
||||
h2 = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "Handshake-response header or range (H2).";
|
||||
};
|
||||
h3 = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "Cookie-reply header or range (H3).";
|
||||
};
|
||||
h4 = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "Transport-message header or range (H4).";
|
||||
};
|
||||
i1 = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "First custom signature packet (I1).";
|
||||
};
|
||||
i2 = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "Second custom signature packet (I2).";
|
||||
};
|
||||
i3 = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "Third custom signature packet (I3).";
|
||||
};
|
||||
i4 = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "Fourth custom signature packet (I4).";
|
||||
};
|
||||
i5 = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "Fifth custom signature packet (I5).";
|
||||
};
|
||||
headerProtectionKey = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "Inline AWG 3 header-protection key. Prefer headerProtectionKeyFile.";
|
||||
};
|
||||
headerProtectionKeyFile = mkOption {
|
||||
type = optionalString;
|
||||
default = null;
|
||||
description = "Runtime path containing the AWG 3 header-protection key.";
|
||||
};
|
||||
contentPaddingAddition = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "AWG 3 content-padding addition or range.";
|
||||
};
|
||||
rekeyAfterTime = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "AWG 3 rekey interval or range.";
|
||||
};
|
||||
rekeyTimeout = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "AWG 3 rekey timeout or range.";
|
||||
};
|
||||
rejectAfterTime = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "AWG 3 reject-after interval or range.";
|
||||
};
|
||||
keepaliveTimeout = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "AWG 3 keepalive timeout or range.";
|
||||
};
|
||||
maxHandshakeAttempts = mkOption {
|
||||
type = optionalRange;
|
||||
default = null;
|
||||
description = "AWG 3 maximum handshake attempts or range.";
|
||||
};
|
||||
randomTrailers = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = "AWG 3 random transport trailers (RandomTrailers).";
|
||||
};
|
||||
disableCookies = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
description = "AWG 3 cookie suppression (DisableCookies).";
|
||||
};
|
||||
# Every AWG obfuscation field is an optional scalar with a one-line description, so they
|
||||
# are declared as tables per value type rather than 27 near-identical mkOption blocks.
|
||||
optional =
|
||||
type: description:
|
||||
mkOption {
|
||||
inherit type description;
|
||||
default = null;
|
||||
};
|
||||
obfuscationType = types.submodule {
|
||||
options =
|
||||
lib.mapAttrs (_: optional optionalUnsigned) {
|
||||
jc = "Junk packet count (Jc).";
|
||||
jmin = "Minimum junk packet size (Jmin).";
|
||||
jmax = "Maximum junk packet size (Jmax).";
|
||||
s1 = "Handshake-init padding (S1).";
|
||||
s2 = "Handshake-response padding (S2).";
|
||||
s3 = "Cookie-reply padding (S3).";
|
||||
s4 = "Transport-message padding (S4).";
|
||||
}
|
||||
// lib.mapAttrs (_: optional optionalRange) {
|
||||
h1 = "Handshake-init header or range (H1).";
|
||||
h2 = "Handshake-response header or range (H2).";
|
||||
h3 = "Cookie-reply header or range (H3).";
|
||||
h4 = "Transport-message header or range (H4).";
|
||||
contentPaddingAddition = "AWG 3 content-padding addition or range.";
|
||||
rekeyAfterTime = "AWG 3 rekey interval or range.";
|
||||
rekeyTimeout = "AWG 3 rekey timeout or range.";
|
||||
rejectAfterTime = "AWG 3 reject-after interval or range.";
|
||||
keepaliveTimeout = "AWG 3 keepalive timeout or range.";
|
||||
maxHandshakeAttempts = "AWG 3 maximum handshake attempts or range.";
|
||||
}
|
||||
// lib.mapAttrs (_: optional optionalString) {
|
||||
i1 = "First custom signature packet (I1).";
|
||||
i2 = "Second custom signature packet (I2).";
|
||||
i3 = "Third custom signature packet (I3).";
|
||||
i4 = "Fourth custom signature packet (I4).";
|
||||
i5 = "Fifth custom signature packet (I5).";
|
||||
headerProtectionKey = "Inline AWG 3 header-protection key. Prefer headerProtectionKeyFile.";
|
||||
headerProtectionKeyFile = "Runtime path containing the AWG 3 header-protection key.";
|
||||
}
|
||||
// lib.mapAttrs (_: optional (types.nullOr types.bool)) {
|
||||
randomTrailers = "AWG 3 random transport trailers (RandomTrailers).";
|
||||
disableCookies = "AWG 3 cookie suppression (DisableCookies).";
|
||||
};
|
||||
};
|
||||
|
||||
settingsType = types.submodule {
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (import ./amnezia-wg.nix { inherit lib; }) obfuscationType;
|
||||
nullStr =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
inherit description example;
|
||||
};
|
||||
inherit (import ../lib.nix { inherit lib; }) nullStr;
|
||||
|
||||
userType = types.submodule {
|
||||
options = {
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
nullStr =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
inherit description example;
|
||||
};
|
||||
inherit (import ../lib.nix { inherit lib; }) nullStr;
|
||||
nullAttrs =
|
||||
description: example:
|
||||
mkOption {
|
||||
|
||||
@@ -3,19 +3,7 @@
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
t = import ./types.nix { inherit lib; };
|
||||
list =
|
||||
description: example:
|
||||
mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
inherit description example;
|
||||
};
|
||||
bool =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.bool;
|
||||
inherit default description;
|
||||
};
|
||||
inherit (import ./lib.nix { inherit lib; }) list bool;
|
||||
in
|
||||
{
|
||||
options.services.proxy-suite.zapret = {
|
||||
|
||||
@@ -2,12 +2,7 @@
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
int =
|
||||
default: description:
|
||||
mkOption {
|
||||
type = types.ints.positive;
|
||||
inherit default description;
|
||||
};
|
||||
int = (import ./lib.nix { inherit lib; }).positiveInt;
|
||||
fromSource = what: "null uses the ${what} of strategySource.";
|
||||
in
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user