You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.services.zapret;
whitelist = lib.optionalString (
cfg.whitelist != null
) "--hostlist ${pkgs.writeText "zapret-whitelist" (lib.concatStringsSep "\n" cfg.whitelist)}";
in
{
options.services.zapret = {
enable = mkEnableOption "DPI bypass multi platform service";
package = mkPackageOption pkgs "zapret" { };
settings = mkOption {
type = types.lines;
default = "";
example = ''
TPWS_OPT="--hostspell=HOST --split-http-req=method --split-pos=3 --oob"
NFQWS_OPT_DESYNC="--dpi-desync-ttl=5"
'';
description = ''
Rules for zapret to work. Run ```nix-shell -p zapret --command blockcheck``` to get values to pass here.
Config example can be found here https://github.com/bol-van/zapret/blob/master/config.default
'';
};
firewallType = mkOption {
type = types.enum [
"iptables"
"nftables"
];
default = "iptables";
description = ''
Which firewall zapret should use
'';
};
disableIpv6 = mkOption {
type = types.bool;
# recommended by upstream
default = true;
description = ''
Disable or enable usage of IpV6 by zapret
'';
};
whitelist = mkOption {
type = with lib.types; nullOr (listOf str);
default = null;
description = ''
Specify a list of domains to bypass. All other domains will be ignored.
It is recommended to specify the whitelist. This will make sure that other resources won't be affected by this service
'';
};
nfqws_opt_general = mkOption {
type = types.str;
default = "";
description = ''
Specify default bypass parameters for Zapret binary.
'';
};
mode = mkOption {
type = types.enum [
"tpws"
"tpws-socks"
"nfqws"
"filter"
"custom"
];
default = "tpws";
description = ''
Which mode zapret should use
'';
};
};
config = mkIf cfg.enable {
users.users.tpws = {
isSystemUser = true;
group = "tpws";
};
users.groups.tpws = { };
systemd.services.zapret = {
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
path = with pkgs; [
(if cfg.firewallType == "iptables" then iptables else nftables)
gawk
ipset
sysctl
];
serviceConfig = {
Type = "forking";
Restart = "no";
TimeoutSec = "30sec";
IgnoreSIGPIPE = "no";
KillMode = "none";
GuessMainPID = "no";
RemainAfterExit = "no";
ExecStart = "${cfg.package}/bin/zapret start";
ExecStop = "${cfg.package}/bin/zapret stop";
EnvironmentFile = pkgs.writeText "${cfg.package.pname}-environment" (concatStrings [
''
MODE=${cfg.mode}
FWTYPE=${cfg.firewallType}
DISABLE_IPV6=${if cfg.disableIpv6 then "1" else "0"}
NFQWS_OPT_DESYNC="${cfg.nfqws_opt_general} ${whitelist}"
''
cfg.settings
]);
# hardening
DevicePolicy = "closed";
KeyringMode = "private";
PrivateTmp = true;
PrivateMounts = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectSystem = "strict";
ProtectProc = "invisible";
RemoveIPC = true;
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
};
};
};
}
If I were to execute `init.d/sysv/init.d start` by itself, it doesn't have enough permissions without root, but ends without any output with root (using equivalent environment)
The text was updated successfully, but these errors were encountered:
Seems to be the same issue as #793, but since no solution was provided, here we go again.
zapret configuration
Whitelist here is from 50-discord.
zapret service definition
The text was updated successfully, but these errors were encountered: