nixos: tor: rename portSpec -> port, type all "port"s properly

This commit is contained in:
SLNOS 2017-03-01 00:00:00 +00:00 committed by Jan Malakhovski
parent 30a3cccd07
commit 2c4a925ab0
2 changed files with 20 additions and 19 deletions

View File

@ -25,6 +25,7 @@ with lib;
(mkRenamedOptionModule [ "services" "sslh" "host" ] [ "services" "sslh" "listenAddress" ]) (mkRenamedOptionModule [ "services" "sslh" "host" ] [ "services" "sslh" "listenAddress" ])
(mkRenamedOptionModule [ "services" "statsd" "host" ] [ "services" "statsd" "listenAddress" ]) (mkRenamedOptionModule [ "services" "statsd" "host" ] [ "services" "statsd" "listenAddress" ])
(mkRenamedOptionModule [ "services" "subsonic" "host" ] [ "services" "subsonic" "listenAddress" ]) (mkRenamedOptionModule [ "services" "subsonic" "host" ] [ "services" "subsonic" "listenAddress" ])
(mkRenamedOptionModule [ "services" "tor" "relay" "portSpec" ] [ "services" "tor" "relay" "port" ])
(mkRenamedOptionModule [ "jobs" ] [ "systemd" "services" ]) (mkRenamedOptionModule [ "jobs" ] [ "systemd" "services" ])
(mkRenamedOptionModule [ "services" "gitlab" "stateDir" ] [ "services" "gitlab" "statePath" ]) (mkRenamedOptionModule [ "services" "gitlab" "stateDir" ] [ "services" "gitlab" "statePath" ])

View File

@ -17,7 +17,7 @@ let
GeoIPv6File ${pkgs.tor.geoip}/share/tor/geoip6 GeoIPv6File ${pkgs.tor.geoip}/share/tor/geoip6
''} ''}
${optint "ControlPort" cfg.controlPort} ${optint "ControlPort" (toString cfg.controlPort)}
'' ''
# Client connection config # Client connection config
+ optionalString cfg.client.enable '' + optionalString cfg.client.enable ''
@ -27,7 +27,7 @@ let
'' ''
# Relay config # Relay config
+ optionalString cfg.relay.enable '' + optionalString cfg.relay.enable ''
ORPort ${cfg.relay.portSpec} ORPort ${toString cfg.relay.port}
${opt "Address" cfg.relay.address} ${opt "Address" cfg.relay.address}
${opt "Nickname" cfg.relay.nickname} ${opt "Nickname" cfg.relay.nickname}
${opt "ContactInfo" cfg.relay.contactInfo} ${opt "ContactInfo" cfg.relay.contactInfo}
@ -56,7 +56,7 @@ let
+ concatStrings (flip mapAttrsToList cfg.hiddenServices (n: v: '' + concatStrings (flip mapAttrsToList cfg.hiddenServices (n: v: ''
HiddenServiceDir ${torDirectory}/onion/${v.name} HiddenServiceDir ${torDirectory}/onion/${v.name}
${flip concatMapStrings v.map (p: '' ${flip concatMapStrings v.map (p: ''
HiddenServicePort ${p.port} ${p.destination} HiddenServicePort ${toString p.port} ${p.destination}
'')} '')}
'')) ''))
+ cfg.extraConfig; + cfg.extraConfig;
@ -98,7 +98,7 @@ in
}; };
controlPort = mkOption { controlPort = mkOption {
type = types.nullOr types.int; type = types.nullOr (types.either types.int types.str);
default = null; default = null;
example = 9051; example = 9051;
description = '' description = ''
@ -185,7 +185,7 @@ in
Setting this to true requires setting Setting this to true requires setting
<option>services.tor.relay.role</option> <option>services.tor.relay.role</option>
and and
<option>services.tor.relay.portSpec</option> <option>services.tor.relay.port</option>
options. options.
''; '';
}; };
@ -307,10 +307,10 @@ in
<para> <para>
Switching to this role after measurable time in Switching to this role after measurable time in
"bridge" role is pretty useless as some Tor users would have "bridge" role is pretty useless as some Tor users
learned about your node already. would have learned about your node already. In the
In the latter case you can still change latter case you can still change
<option>portSpec</option> option. <option>port</option> option.
</para> </para>
<para> <para>
@ -403,9 +403,9 @@ in
''; '';
}; };
portSpec = mkOption { port = mkOption {
type = types.str; type = types.either types.int types.str;
example = "143"; example = 143;
description = '' description = ''
What port to advertise for Tor connections. This corresponds to the What port to advertise for Tor connections. This corresponds to the
<literal>ORPort</literal> section in the Tor manual; see <literal>ORPort</literal> section in the Tor manual; see
@ -477,8 +477,8 @@ in
default = {}; default = {};
example = literalExample '' example = literalExample ''
{ "my-hidden-service-example".map = [ { "my-hidden-service-example".map = [
{ port = "22"; } # map ssh port to this machine's ssh { port = 22; } # map ssh port to this machine's ssh
{ port = "80"; toPort = "8080"; } # map http port to whatever runs on 8080 { port = 80; toPort = 8080; } # map http port to whatever runs on 8080
{ port = "sip"; toHost = "mail.example.com"; toPort = "imap"; } # because we can { port = "sip"; toHost = "mail.example.com"; toPort = "imap"; } # because we can
]; ];
} }
@ -506,8 +506,8 @@ in
options = { options = {
port = mkOption { port = mkOption {
type = types.str; type = types.either types.int types.str;
example = "80"; example = 80;
description = '' description = ''
Hidden service port to "bind to". Hidden service port to "bind to".
''; '';
@ -526,8 +526,8 @@ in
}; };
toPort = mkOption { toPort = mkOption {
type = types.str; type = types.either types.int types.str;
example = "8080"; example = 8080;
description = "Mapping destination port."; description = "Mapping destination port.";
}; };
@ -535,7 +535,7 @@ in
config = { config = {
toPort = mkDefault config.port; toPort = mkDefault config.port;
destination = mkDefault "${config.toHost}:${config.toPort}"; destination = mkDefault "${config.toHost}:${toString config.toPort}";
}; };
})); }));
}; };