1 { config, lib, pkgs, ... }:
6 cfg = config.services.snowflake-proxy;
10 services.snowflake-proxy = {
11 enable = mkEnableOption (lib.mdDoc "System to defeat internet censorship");
14 description = lib.mdDoc "Broker URL (default \"https://snowflake-broker.torproject.net/\")";
15 type = with types; nullOr str;
20 description = lib.mdDoc "Limits the amount of maximum concurrent clients allowed.";
21 type = with types; nullOr int;
26 description = lib.mdDoc "websocket relay URL (default \"wss://snowflake.bamsoftware.com/\")";
27 type = with types; nullOr str;
32 description = lib.mdDoc "STUN broker URL (default \"stun:stun.stunprotocol.org:3478\")";
33 type = with types; nullOr str;
39 config = mkIf cfg.enable {
40 systemd.services.snowflake-proxy = {
41 wantedBy = [ "network-online.target" ];
44 "${pkgs.snowflake}/bin/proxy " + concatStringsSep " " (
45 optional (cfg.broker != null) "-broker ${cfg.broker}"
46 ++ optional (cfg.capacity != null) "-capacity ${builtins.toString cfg.capacity}"
47 ++ optional (cfg.relay != null) "-relay ${cfg.relay}"
48 ++ optional (cfg.stun != null) "-stun ${cfg.stun}"
52 # Refer to systemd.exec(5) for option descriptions.
53 CapabilityBoundingSet = "";
55 # implies RemoveIPC=, PrivateTmp=, NoNewPrivileges=, RestrictSUIDSGID=,
56 # ProtectSystem=strict, ProtectHome=read-only
58 LockPersonality = true;
59 PrivateDevices = true;
63 ProtectControlGroups = true;
65 ProtectHostname = true;
66 ProtectKernelLogs = true;
67 ProtectProc = "invisible";
68 ProtectKernelModules = true;
69 ProtectKernelTunables = true;
70 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
71 RestrictNamespaces = true;
72 RestrictRealtime = true;
73 SystemCallArchitectures = "native";
74 SystemCallFilter = [ "@system-service" "~@privileged" ];
80 meta.maintainers = with maintainers; [ yayayayaka ];