nixos/tor: expose control socket
This commit is contained in:
parent
273fd896bc
commit
cb9c1c63c9
|
@ -5,6 +5,7 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.tor;
|
cfg = config.services.tor;
|
||||||
torDirectory = "/var/lib/tor";
|
torDirectory = "/var/lib/tor";
|
||||||
|
torRunDirectory = "/run/tor";
|
||||||
|
|
||||||
opt = name: value: optionalString (value != null) "${name} ${value}";
|
opt = name: value: optionalString (value != null) "${name} ${value}";
|
||||||
optint = name: value: optionalString (value != null && value != 0) "${name} ${toString value}";
|
optint = name: value: optionalString (value != null && value != 0) "${name} ${toString value}";
|
||||||
|
@ -38,6 +39,7 @@ let
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optint "ControlPort" cfg.controlPort}
|
${optint "ControlPort" cfg.controlPort}
|
||||||
|
${optionalString cfg.controlSocket.enable "ControlSocket ${torRunDirectory}/control GroupWritable RelaxDirModeCheck"}
|
||||||
''
|
''
|
||||||
# Client connection config
|
# Client connection config
|
||||||
+ optionalString cfg.client.enable ''
|
+ optionalString cfg.client.enable ''
|
||||||
|
@ -140,6 +142,17 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
controlSocket = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Wheter to enable Tor control socket. Control socket is created
|
||||||
|
in <literal>${torRunDirectory}/control</literal>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
client = {
|
client = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -692,7 +705,7 @@ in
|
||||||
|
|
||||||
# Translated from the upstream contrib/dist/tor.service.in
|
# Translated from the upstream contrib/dist/tor.service.in
|
||||||
preStart = ''
|
preStart = ''
|
||||||
install -o tor -g tor -d ${torDirectory}/onion
|
install -o tor -g tor -d ${torDirectory}/onion ${torRunDirectory}
|
||||||
${pkgs.tor}/bin/tor -f ${torRcFile} --verify-config
|
${pkgs.tor}/bin/tor -f ${torRcFile} --verify-config
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -716,7 +729,7 @@ in
|
||||||
DevicePolicy = "closed";
|
DevicePolicy = "closed";
|
||||||
InaccessibleDirectories = "/home";
|
InaccessibleDirectories = "/home";
|
||||||
ReadOnlyDirectories = "/";
|
ReadOnlyDirectories = "/";
|
||||||
ReadWriteDirectories = torDirectory;
|
ReadWriteDirectories = [torDirectory torRunDirectory];
|
||||||
NoNewPrivileges = "yes";
|
NoNewPrivileges = "yes";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue