L-Nafaryus
a4d8f5232e
Some checks failed
nix / check (push) Failing after 1m15s
flake: fix name conventions flake: configurations -> lib.preconfiguredModules flake.packages: rework platform dependency with convient module and evaluator `lib.collectPackages` packages.bonfire-docs: convient evaluators `nixosModulesDoc` and `packagesDoc` new: packages.postgresql: container image new: packages.redis: container image remove: packages.lego: needed dns provider was added to lego and nixpkgs packages.netgen: broken
64 lines
1.4 KiB
Nix
64 lines
1.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
bonPkgs,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.services.spoofdpi;
|
|
in {
|
|
options.services.spoofdpi = {
|
|
enable = mkEnableOption "SpoofDPI service";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = bonPkgs.spoofdpi;
|
|
defaultText = literalExpression "bonPkgs.spoofdpi";
|
|
description = "The package to use.";
|
|
};
|
|
|
|
address = mkOption rec {
|
|
type = types.str;
|
|
default = "127.0.0.1";
|
|
example = default;
|
|
description = "Listen address.";
|
|
};
|
|
|
|
port = mkOption rec {
|
|
type = types.port;
|
|
default = 8080;
|
|
example = default;
|
|
description = "Port.";
|
|
};
|
|
|
|
openFirewall = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = "Open `services.spoofdpi.port`.";
|
|
};
|
|
|
|
dns = mkOption rec {
|
|
type = types.str;
|
|
default = "8.8.8.8";
|
|
example = default;
|
|
description = "DNS server.";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.spoofdpi = {
|
|
wantedBy = ["multi-user.target"];
|
|
after = ["network.target"];
|
|
serviceConfig = {
|
|
Restart = "on-failure";
|
|
ExecStart = "${lib.getExe cfg.package} -no-banner -addr ${cfg.address} -port ${toString cfg.port} -dns ${cfg.dns}";
|
|
DynamicUser = "yes";
|
|
};
|
|
};
|
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
allowedTCPPorts = [cfg.port];
|
|
};
|
|
};
|
|
}
|