modules/byedpi: improve configs
This commit is contained in:
parent
cfca967a6e
commit
9611f6850b
2 changed files with 24 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
|
@ -17,17 +17,13 @@
|
|||
################################################################################
|
||||
local.services.byedpi = {
|
||||
enable = true;
|
||||
enableProxy = true;
|
||||
settings = {
|
||||
port = 1081;
|
||||
fake = 1;
|
||||
ttl = 8;
|
||||
};
|
||||
};
|
||||
networking.proxy = rec {
|
||||
allProxy = "http://localhost:${toString config.local.services.byedpi.settings.port}";
|
||||
httpProxy = allProxy;
|
||||
httpsProxy = allProxy;
|
||||
};
|
||||
|
||||
# local.services.i2pd.enable = true;
|
||||
# local.services.kubo.enable = true;
|
||||
|
|
|
@ -17,12 +17,12 @@ let
|
|||
no-domain = !cfg.settings.domain.enable;
|
||||
};
|
||||
|
||||
|
||||
strOrNum = with lib.types; either str number;
|
||||
|
||||
splitType = with lib.types; nullOr (either strOrNum (listOf strOrNum));
|
||||
|
||||
mkSplitOption = description: lib.mkOption {
|
||||
mkSplitOption = let
|
||||
splitType = with lib.types;
|
||||
let strOrInt = either str int;
|
||||
in nullOr (either strOrInt (listOf strOrInt));
|
||||
in
|
||||
description: lib.mkOption {
|
||||
inherit description;
|
||||
type = splitType;
|
||||
default = null;
|
||||
|
@ -33,6 +33,7 @@ in
|
|||
enable = mkEnableOption "byedpi";
|
||||
package = mkPackageOption pkgs "byedpi" { };
|
||||
openFirewall = mkEnableOption "Whether to open the required firewall ports in the firewall.";
|
||||
enableProxy = mkEnableOption "Whether to enable systemwide networking proxy";
|
||||
settings = {
|
||||
ip = mkOption {
|
||||
type = types.str;
|
||||
|
@ -40,21 +41,21 @@ in
|
|||
default = "0.0.0.0";
|
||||
};
|
||||
port = mkOption {
|
||||
type = types.number;
|
||||
type = types.ints.u16;
|
||||
description = "Listening port";
|
||||
default = 1080;
|
||||
};
|
||||
bufferSize = mkOption {
|
||||
type = types.number;
|
||||
type = types.int;
|
||||
description = "Buffer size";
|
||||
default = 16384;
|
||||
};
|
||||
debugLevel = mkOption {
|
||||
type = types.number; # 0, 1, 2
|
||||
type = types.ints.between 0 2;
|
||||
default = 0;
|
||||
};
|
||||
connectionLimit = mkOption {
|
||||
type = types.number;
|
||||
type = types.int;
|
||||
description = "Connection count limit";
|
||||
default = 512;
|
||||
};
|
||||
|
@ -63,7 +64,7 @@ in
|
|||
tcpFastOpen.enable = mkEnableOption "Enable TCP Fast Open";
|
||||
|
||||
ttl = mkOption {
|
||||
type = types.number;
|
||||
type = types.int;
|
||||
default = 8;
|
||||
};
|
||||
split = mkSplitOption "Split packet at n";
|
||||
|
@ -85,6 +86,12 @@ in
|
|||
|
||||
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.settings.port ];
|
||||
|
||||
networking.proxy = lib.mkIf cfg.enableProxy rec {
|
||||
allProxy = "http://${cfg.settings.ip}:${toString cfg.settings.port}";
|
||||
httpProxy = allProxy;
|
||||
httpsProxy = allProxy;
|
||||
};
|
||||
|
||||
systemd.services.byedpi = {
|
||||
description = "Byedpi (Bypass DPI)";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue