diff options
author | Evgeny Egorochkin <phreedom@yandex.ru> | 2014-12-16 19:27:58 +0200 |
---|---|---|
committer | Evgeny Egorochkin <phreedom@yandex.ru> | 2014-12-19 08:05:41 +0200 |
commit | da118cf60bdad29cc8ed2abf05f1f97be4f327fc (patch) | |
tree | 49aa1627ea2716f0dfffcc64c46123d5aed3e922 /nixos | |
parent | ebf216bd56d13557f96471e8f065ed832c8c4e42 (diff) | |
download | nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.tar nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.tar.gz nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.tar.bz2 nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.tar.lz nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.tar.xz nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.tar.zst nixlib-da118cf60bdad29cc8ed2abf05f1f97be4f327fc.zip |
Revert "nixos: Remove torify module"
tsocks is still useful because it's less strict This reverts commit 1b26faeb6994151b8f8842f340fe4c1b820f09fb.
Diffstat (limited to 'nixos')
-rwxr-xr-x | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/security/torify.nix | 69 |
2 files changed, 70 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index e0d614e61bfb..1005e281f9b7 100755 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -307,6 +307,7 @@ ./services/security/fprot.nix ./services/security/frandom.nix ./services/security/haveged.nix + ./services/security/torify.nix ./services/security/tor.nix ./services/security/torsocks.nix ./services/system/cloud-init.nix diff --git a/nixos/modules/services/security/torify.nix b/nixos/modules/services/security/torify.nix new file mode 100644 index 000000000000..53f48a714b4b --- /dev/null +++ b/nixos/modules/services/security/torify.nix @@ -0,0 +1,69 @@ +{ config, lib, pkgs, ... }: +with lib; +let + + cfg = config.services.tor; + + torify = pkgs.writeTextFile { + name = "torify"; + text = '' + #!${pkgs.stdenv.shell} + TSOCKS_CONF_FILE=${pkgs.writeText "tsocks.conf" cfg.torify.config} LD_PRELOAD="${pkgs.tsocks}/lib/libtsocks.so $LD_PRELOAD" "$@" + ''; + executable = true; + destination = "/bin/torify"; + }; + +in + +{ + + ###### interface + + options = { + + services.tor.torify = { + + enable = mkOption { + default = cfg.client.enable; + description = '' + Whether to build torify scipt to relay application traffic via TOR. + ''; + }; + + server = mkOption { + default = "localhost:9050"; + example = "192.168.0.20"; + description = '' + IP address of TOR client to use. + ''; + }; + + config = mkOption { + default = ""; + description = '' + Extra configuration. Contents will be added verbatim to TSocks + configuration file. + ''; + }; + + }; + + }; + + ###### implementation + + config = mkIf cfg.torify.enable { + + environment.systemPackages = [ torify ]; # expose it to the users + + services.tor.torify.config = '' + server = ${toString(head (splitString ":" cfg.torify.server))} + server_port = ${toString(tail (splitString ":" cfg.torify.server))} + + local = 127.0.0.0/255.128.0.0 + local = 127.128.0.0/255.192.0.0 + ''; + }; + +} |