@@ -28,15 +28,15 @@ let
2828 };
2929
3030 mkKeyedEndpointOpt = name: addr: port: keyFile:
31− (mkEndpointOpt name addr port) // {
32− keys = mkOption {
33− type = types.str;
34− default = "";
35− description = ''
36− File to persist ${lib.toUpper name} keys.
37− '';
31+ (mkEndpointOpt name addr port) // {
32+ keys = mkOption {
33+ type = types.str;
34+ default = "";
35+ description = ''
36+ File to persist ${lib.toUpper name} keys.
37+ '';
38+ };
3839 };
39− };
4040
4141 commonTunOpts = let
4242 i2cpOpts = {
@@ -59,7 +59,7 @@ let
5959 description = "Number of ElGamal/AES tags to send.";
6060 default = 40;
6161 };
62− destination = mkOption {
62+ destination = mkOption {
6363 type = types.str;
6464 description = "Remote endpoint, I2P hostname or b32.i2p address.";
6565 };
@@ -70,88 +70,91 @@ let
7070 };
7171 } // mkEndpointOpt name "127.0.0.1" 0;
7272
73− i2pdConf = pkgs.writeText "i2pd.conf"
74− ''
75− ipv4 = ${boolToString cfg.enableIPv4}
76− ipv6 = ${boolToString cfg.enableIPv6}
77− notransit = ${boolToString cfg.notransit}
78− floodfill = ${boolToString cfg.floodfill}
79− netid = ${toString cfg.netid}
80− ${if isNull cfg.bandwidth then "" else "bandwidth = ${toString cfg.bandwidth}" }
81− ${if isNull cfg.port then "" else "port = ${toString cfg.port}"}
82−
83− [limits]
84− transittunnels = ${toString cfg.limits.transittunnels}
85−
86− [upnp]
87− enabled = ${boolToString cfg.upnp.enable}
88− name = ${cfg.upnp.name}
89−
90− [precomputation]
91− elgamal = ${boolToString cfg.precomputation.elgamal}
92−
93− [reseed]
94− verify = ${boolToString cfg.reseed.verify}
95− file = ${cfg.reseed.file}
96− urls = ${builtins.concatStringsSep "," cfg.reseed.urls}
97−
98− [addressbook]
99− defaulturl = ${cfg.addressbook.defaulturl}
100− subscriptions = ${builtins.concatStringsSep "," cfg.addressbook.subscriptions}
101− ${flip concatMapStrings
73+ i2pdConf = pkgs.writeText "i2pd.conf" ''
74+ # DO NOT EDIT -- this file has been generated automatically.
75+ loglevel = ${cfg.logLevel}
76+
77+ ipv4 = ${boolToString cfg.enableIPv4}
78+ ipv6 = ${boolToString cfg.enableIPv6}
79+ notransit = ${boolToString cfg.notransit}
80+ floodfill = ${boolToString cfg.floodfill}
81+ netid = ${toString cfg.netid}
82+ ${if isNull cfg.bandwidth then "" else "bandwidth = ${toString cfg.bandwidth}" }
83+ ${if isNull cfg.port then "" else "port = ${toString cfg.port}"}
84+
85+ [limits]
86+ transittunnels = ${toString cfg.limits.transittunnels}
87+
88+ [upnp]
89+ enabled = ${boolToString cfg.upnp.enable}
90+ name = ${cfg.upnp.name}
91+
92+ [precomputation]
93+ elgamal = ${boolToString cfg.precomputation.elgamal}
94+
95+ [reseed]
96+ verify = ${boolToString cfg.reseed.verify}
97+ file = ${cfg.reseed.file}
98+ urls = ${builtins.concatStringsSep "," cfg.reseed.urls}
99+
100+ [addressbook]
101+ defaulturl = ${cfg.addressbook.defaulturl}
102+ subscriptions = ${builtins.concatStringsSep "," cfg.addressbook.subscriptions}
103+
104+ ${flip concatMapStrings
102105 (collect (proto: proto ? port && proto ? address && proto ? name) cfg.proto)
103− (proto: let portStr = toString proto.port; in
104− ''
105− [${proto.name}]
106− enabled = ${boolToString proto.enable}
107− address = ${proto.address}
108− port = ${toString proto.port}
109− ${if proto ? keys then "keys = ${proto.keys}" else ""}
110− ${if proto ? auth then "auth = ${boolToString proto.auth}" else ""}
111− ${if proto ? user then "user = ${proto.user}" else ""}
112− ${if proto ? pass then "pass = ${proto.pass}" else ""}
113− ${if proto ? outproxy then "outproxy = ${proto.outproxy}" else ""}
114− ${if proto ? outproxyPort then "outproxyport = ${toString proto.outproxyPort}" else ""}
115− '')
116− }
106+ (proto: let portStr = toString proto.port; in ''
107+ [${proto.name}]
108+ enabled = ${boolToString proto.enable}
109+ address = ${proto.address}
110+ port = ${toString proto.port}
111+ ${if proto ? keys then "keys = ${proto.keys}" else ""}
112+ ${if proto ? auth then "auth = ${boolToString proto.auth}" else ""}
113+ ${if proto ? user then "user = ${proto.user}" else ""}
114+ ${if proto ? pass then "pass = ${proto.pass}" else ""}
115+ ${if proto ? outproxy then "outproxy = ${proto.outproxy}" else ""}
116+ ${if proto ? outproxyPort then "outproxyport = ${toString proto.outproxyPort}" else ""}
117+ '')
118+ }
117119 '';
118120
119121 i2pdTunnelConf = pkgs.writeText "i2pd-tunnels.conf" ''
120− ${flip concatMapStrings
121− (collect (tun: tun ? port && tun ? destination) cfg.outTunnels)
122− (tun: let portStr = toString tun.port; in ''
123− [${tun.name}]
124− type = client
125− destination = ${tun.destination}
126− keys = ${tun.keys}
127− address = ${tun.address}
128− port = ${toString tun.port}
129− inbound.length = ${toString tun.inbound.length}
130− outbound.length = ${toString tun.outbound.length}
131− inbound.quantity = ${toString tun.inbound.quantity}
132− outbound.quantity = ${toString tun.outbound.quantity}
133− crypto.tagsToSend = ${toString tun.crypto.tagsToSend}
134− '')
135− }
136− ${flip concatMapStrings
137− (collect (tun: tun ? port && tun ? host) cfg.inTunnels)
138− (tun: let portStr = toString tun.port; in ''
139− [${tun.name}]
140− type = server
141− destination = ${tun.destination}
142− keys = ${tun.keys}
143− host = ${tun.address}
144− port = ${tun.port}
145− inport = ${tun.inPort}
146− accesslist = ${builtins.concatStringsSep "," tun.accessList}
147− '')
148− }
122+ # DO NOT EDIT -- this file has been generated automatically.
123+ ${flip concatMapStrings
124+ (collect (tun: tun ? port && tun ? destination) cfg.outTunnels)
125+ (tun: let portStr = toString tun.port; in ''
126+ [${tun.name}]
127+ type = client
128+ destination = ${tun.destination}
129+ keys = ${tun.keys}
130+ address = ${tun.address}
131+ port = ${toString tun.port}
132+ inbound.length = ${toString tun.inbound.length}
133+ outbound.length = ${toString tun.outbound.length}
134+ inbound.quantity = ${toString tun.inbound.quantity}
135+ outbound.quantity = ${toString tun.outbound.quantity}
136+ crypto.tagsToSend = ${toString tun.crypto.tagsToSend}
137+ '')
138+ }
139+ ${flip concatMapStrings
140+ (collect (tun: tun ? port && tun ? host) cfg.inTunnels)
141+ (tun: let portStr = toString tun.port; in ''
142+ [${tun.name}]
143+ type = server
144+ destination = ${tun.destination}
145+ keys = ${tun.keys}
146+ host = ${tun.address}
147+ port = ${tun.port}
148+ inport = ${tun.inPort}
149+ accesslist = ${builtins.concatStringsSep "," tun.accessList}
150+ '')
151+ }
149152 '';
150153
151154 i2pdSh = pkgs.writeScriptBin "i2pd" ''
152155 #!/bin/sh
153− ${pkgs.i2pd}/bin/i2pd \
154− ${if isNull cfg.extIp then "" else "--host="+cfg.extIp} \
156+ exec ${pkgs.i2pd}/bin/i2pd \
157+ ${if isNull cfg.address then "" else "--host="+cfg.address} \
155158 --conf=${i2pdConf} \
156159 --tunconf=${i2pdTunnelConf}
157160 '';
@@ -176,11 +179,23 @@ in
176179 '';
177180 };
178181
179− extIp = mkOption {
182+ logLevel = mkOption {
183+ type = types.enum ["debug" "info" "warn" "error"];
184+ default = "error";
185+ description = ''
186+ The log level. <command>i2pd</command> defaults to "info"
187+ but that generates copious amounts of log messages.
188+
189+ We default to "error" which is similar to the default log
190+ level of <command>tor</command>.
191+ '';
192+ };
193+
194+ address = mkOption {
180195 type = with types; nullOr str;
181196 default = null;
182197 description = ''
183− Your external IP.
198+ Your external IP or hostname.
184199 '';
185200 };
186201
@@ -213,7 +228,7 @@ in
213228 default = null;
214229 description = ''
215230 Set a router bandwidth limit integer in KBps.
216− If not set, i2pd defaults to 32KBps.
231+ If not set, <command>i2pd</command> defaults to 32KBps.
217232 '';
218233 };
219234
@@ -261,9 +276,14 @@ in
261276
262277 precomputation.elgamal = mkOption {
263278 type = types.bool;
264− default = false;
279+ default = true;
265280 description = ''
266− Use ElGamal precomputated tables.
281+ Whenever to use precomputated tables for ElGamal.
282+ <command>i2pd</command> defaults to <literal>false</literal>
283+ to save 64M of memory (and looses some performance).
284+
285+ We default to <literal>true</literal> as that is what most
286+ users want anyway.
267287 '';
268288 };
269289
@@ -353,7 +373,7 @@ in
353373 };
354374 };
355375
356− proto.httpProxy = mkKeyedEndpointOpt "httpproxy" "127.0.0.1" 4446 "";
376+ proto.httpProxy = mkKeyedEndpointOpt "httpproxy" "127.0.0.1" 4444 "";
357377 proto.socksProxy = (mkKeyedEndpointOpt "socksproxy" "127.0.0.1" 4447 "")
358378 // {
359379 outproxy = mkOption {