mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 06:45:16 +01:00
resurrect torsocks-faster
This commit is contained in:
parent
eb0874d5ff
commit
9225af50d0
1 changed files with 26 additions and 5 deletions
|
@ -6,9 +6,9 @@ let
|
|||
cfg = config.services.tor.torsocks;
|
||||
optionalNullStr = b: v: optionalString (b != null) v;
|
||||
|
||||
configFile = ''
|
||||
TorAddress ${toString (head (splitString ":" cfg.server))}
|
||||
TorPort ${toString (tail (splitString ":" cfg.server))}
|
||||
configFile = server: ''
|
||||
TorAddress ${toString (head (splitString ":" server))}
|
||||
TorPort ${toString (tail (splitString ":" server))}
|
||||
|
||||
OnionAddrRange ${cfg.onionAddrRange}
|
||||
|
||||
|
@ -19,6 +19,17 @@ let
|
|||
|
||||
AllowInbound ${if cfg.allowInbound then "1" else "0"}
|
||||
'';
|
||||
|
||||
wrapTorsocks = name: server: pkgs.writeTextFile {
|
||||
name = name;
|
||||
text = ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
TORSOCKS_CONF_FILE=${pkgs.writeText "torsocks.conf" (configFile server)} ${pkgs.torsocks}/bin/torsocks "$@"
|
||||
'';
|
||||
executable = true;
|
||||
destination = "/bin/${name}";
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
@ -42,6 +53,16 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
fasterServer = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1:9063";
|
||||
example = "192.168.0.20:1234";
|
||||
description = ''
|
||||
IP/Port of the Tor SOCKS server for torsocks-faster wrapper suitable for HTTP.
|
||||
Currently, hostnames are NOT supported by torsocks.
|
||||
'';
|
||||
};
|
||||
|
||||
onionAddrRange = mkOption {
|
||||
type = types.str;
|
||||
default = "127.42.42.0/24";
|
||||
|
@ -89,10 +110,10 @@ in
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ pkgs.torsocks ];
|
||||
environment.systemPackages = [ pkgs.torsocks (wrapTorsocks "torsocks-faster" cfg.fasterServer) ];
|
||||
|
||||
environment.etc =
|
||||
[ { source = pkgs.writeText "torsocks.conf" configFile;
|
||||
[ { source = pkgs.writeText "torsocks.conf" (configFile cfg.server);
|
||||
target = "tor/torsocks.conf";
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue