Compare commits

...

3 commits

4 changed files with 25 additions and 24 deletions
flake.nix
hosts/home
modules/nixos/services

View file

@ -86,9 +86,6 @@
(hostname: machine: pkgs.writeShellScript "switch/${hostname}" ''
set -e
${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname} $@
${lib.optionalString machine.config.hardware.pulseaudio.systemWide ''
systemctl restart alsa-store.service
''}
'')
localMachines);
});

View file

@ -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;

View file

@ -17,22 +17,23 @@ 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 {
inherit description;
type = splitType;
default = null;
};
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;
};
in
{
options.local.services.byedpi = with lib; {
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)";

View file

@ -6,6 +6,7 @@ let
addrsViaDefaultInterface = [
# cache.nixos.org
"151.101.86.217/32"
"146.75.118.217/32"
# tbank.ru
"178.248.236.218/32"
];