summary refs log tree commit diff
path: root/nixos/modules/services/security/tor.nix
diff options
context:
space:
mode:
authorSLNOS <anonymous@wired>2017-03-01 00:00:00 +0000
committerJan Malakhovski <oxij@oxij.org>2017-08-22 14:57:07 +0000
commit2c4a925ab07e4ebfd932730b358771e3547be605 (patch)
tree78ff5c734761292006ffaa1036526a202f45f4f1 /nixos/modules/services/security/tor.nix
parent30a3cccd07914155703e9376d9470ef5f24f9a5c (diff)
downloadnixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.tar
nixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.tar.gz
nixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.tar.bz2
nixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.tar.lz
nixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.tar.xz
nixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.tar.zst
nixpkgs-2c4a925ab07e4ebfd932730b358771e3547be605.zip
nixos: tor: rename portSpec -> port, type all "port"s properly
Diffstat (limited to 'nixos/modules/services/security/tor.nix')
-rw-r--r--nixos/modules/services/security/tor.nix38
1 files changed, 19 insertions, 19 deletions
diff --git a/nixos/modules/services/security/tor.nix b/nixos/modules/services/security/tor.nix
index c2851b1dd60..04b065f6ae4 100644
--- a/nixos/modules/services/security/tor.nix
+++ b/nixos/modules/services/security/tor.nix
@@ -17,7 +17,7 @@ let
       GeoIPv6File ${pkgs.tor.geoip}/share/tor/geoip6
     ''}
 
-    ${optint "ControlPort" cfg.controlPort}
+    ${optint "ControlPort" (toString cfg.controlPort)}
   ''
   # Client connection config
   + optionalString cfg.client.enable  ''
@@ -27,7 +27,7 @@ let
   ''
   # Relay config
   + optionalString cfg.relay.enable ''
-    ORPort ${cfg.relay.portSpec}
+    ORPort ${toString cfg.relay.port}
     ${opt "Address" cfg.relay.address}
     ${opt "Nickname" cfg.relay.nickname}
     ${opt "ContactInfo" cfg.relay.contactInfo}
@@ -56,7 +56,7 @@ let
   + concatStrings (flip mapAttrsToList cfg.hiddenServices (n: v: ''
     HiddenServiceDir ${torDirectory}/onion/${v.name}
     ${flip concatMapStrings v.map (p: ''
-      HiddenServicePort ${p.port} ${p.destination}
+      HiddenServicePort ${toString p.port} ${p.destination}
     '')}
   ''))
   + cfg.extraConfig;
@@ -98,7 +98,7 @@ in
       };
 
       controlPort = mkOption {
-        type = types.nullOr types.int;
+        type = types.nullOr (types.either types.int types.str);
         default = null;
         example = 9051;
         description = ''
@@ -185,7 +185,7 @@ in
             Setting this to true requires setting
             <option>services.tor.relay.role</option>
             and
-            <option>services.tor.relay.portSpec</option>
+            <option>services.tor.relay.port</option>
             options.
           '';
         };
@@ -307,10 +307,10 @@ in
 
                 <para>
                   Switching to this role after measurable time in
-                  "bridge" role is pretty useless as some Tor users would have
-                  learned about your node already.
-                  In the latter case you can still change
-                  <option>portSpec</option> option.
+                  "bridge" role is pretty useless as some Tor users
+                  would have learned about your node already. In the
+                  latter case you can still change
+                  <option>port</option> option.
                 </para>
 
                 <para>
@@ -403,9 +403,9 @@ in
           '';
         };
 
-        portSpec = mkOption {
-          type    = types.str;
-          example = "143";
+        port = mkOption {
+          type    = types.either types.int types.str;
+          example = 143;
           description = ''
             What port to advertise for Tor connections. This corresponds to the
             <literal>ORPort</literal> section in the Tor manual; see
@@ -477,8 +477,8 @@ in
         default = {};
         example = literalExample ''
           { "my-hidden-service-example".map = [
-              { port = "22"; }                   # map ssh port to this machine's ssh
-              { port = "80";  toPort = "8080"; } # map http port to whatever runs on 8080
+              { port = 22; }                # map ssh port to this machine's ssh
+              { port = 80; toPort = 8080; } # map http port to whatever runs on 8080
               { port = "sip"; toHost = "mail.example.com"; toPort = "imap"; } # because we can
             ];
           }
@@ -506,8 +506,8 @@ in
                  options = {
 
                    port = mkOption {
-                     type = types.str;
-                     example = "80";
+                     type = types.either types.int types.str;
+                     example = 80;
                      description = ''
                        Hidden service port to "bind to".
                      '';
@@ -526,8 +526,8 @@ in
                    };
 
                    toPort = mkOption {
-                     type = types.str;
-                     example = "8080";
+                     type = types.either types.int types.str;
+                     example = 8080;
                      description = "Mapping destination port.";
                    };
 
@@ -535,7 +535,7 @@ in
 
                  config = {
                    toPort = mkDefault config.port;
-                   destination = mkDefault "${config.toHost}:${config.toPort}";
+                   destination = mkDefault "${config.toHost}:${toString config.toPort}";
                  };
                }));
              };