nixos: i2pd, update config options
This commit is contained in:
parent
721c3d48e1
commit
4009dbe543
@ -10,7 +10,7 @@ let
|
|||||||
|
|
||||||
extip = "EXTIP=\$(${pkgs.curl.bin}/bin/curl -sf \"http://jsonip.com\" | ${pkgs.gawk}/bin/awk -F'\"' '{print $4}')";
|
extip = "EXTIP=\$(${pkgs.curl.bin}/bin/curl -sf \"http://jsonip.com\" | ${pkgs.gawk}/bin/awk -F'\"' '{print $4}')";
|
||||||
|
|
||||||
toYesNo = b: if b then "yes" else "no";
|
toYesNo = b: if b then "true" else "false";
|
||||||
|
|
||||||
mkEndpointOpt = name: addr: port: {
|
mkEndpointOpt = name: addr: port: {
|
||||||
enable = mkEnableOption name;
|
enable = mkEnableOption name;
|
||||||
@ -31,6 +31,17 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkKeyedEndpointOpt = name: addr: port: keyFile:
|
||||||
|
(mkEndpointOpt name addr port) // {
|
||||||
|
keys = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
File to persist ${lib.toUpper name} keys.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
commonTunOpts = let
|
commonTunOpts = let
|
||||||
i2cpOpts = {
|
i2cpOpts = {
|
||||||
length = mkOption {
|
length = mkOption {
|
||||||
@ -63,19 +74,49 @@ let
|
|||||||
};
|
};
|
||||||
} // mkEndpointOpt name "127.0.0.1" 0;
|
} // mkEndpointOpt name "127.0.0.1" 0;
|
||||||
|
|
||||||
i2pdConf = pkgs.writeText "i2pd.conf" ''
|
i2pdConf = pkgs.writeText "i2pd.conf"
|
||||||
ipv6 = ${toYesNo cfg.enableIPv6}
|
''
|
||||||
notransit = ${toYesNo cfg.notransit}
|
ipv4 = ${toYesNo cfg.enableIPv4}
|
||||||
floodfill = ${toYesNo cfg.floodfill}
|
ipv6 = ${toYesNo cfg.enableIPv6}
|
||||||
${if isNull cfg.port then "" else "port = ${toString cfg.port}"}
|
notransit = ${toYesNo cfg.notransit}
|
||||||
${flip concatMapStrings
|
floodfill = ${toYesNo cfg.floodfill}
|
||||||
(collect (proto: proto ? port && proto ? address && proto ? name) cfg.proto)
|
netid = ${toString cfg.netid}
|
||||||
(proto: let portStr = toString proto.port; in ''
|
${if isNull cfg.bandwidth then "" else "bandwidth = ${toString cfg.bandwidth}" }
|
||||||
[${proto.name}]
|
${if isNull cfg.port then "" else "port = ${toString cfg.port}"}
|
||||||
address = ${proto.address}
|
|
||||||
port = ${toString proto.port}
|
[limits]
|
||||||
enabled = ${toYesNo proto.enable}
|
transittunnels = ${toString cfg.limits.transittunnels}
|
||||||
'')
|
|
||||||
|
[upnp]
|
||||||
|
enabled = ${toYesNo cfg.upnp.enable}
|
||||||
|
name = ${cfg.upnp.name}
|
||||||
|
|
||||||
|
[precomputation]
|
||||||
|
elgamal = ${toYesNo cfg.precomputation.elgamal}
|
||||||
|
|
||||||
|
[reseed]
|
||||||
|
verify = ${toYesNo cfg.reseed.verify}
|
||||||
|
file = ${cfg.reseed.file}
|
||||||
|
urls = ${builtins.concatStringsSep "," cfg.reseed.urls}
|
||||||
|
|
||||||
|
[addressbook]
|
||||||
|
defaulturl = ${cfg.addressbook.defaulturl}
|
||||||
|
subscriptions = ${builtins.concatStringsSep "," cfg.addressbook.subscriptions}
|
||||||
|
${flip concatMapStrings
|
||||||
|
(collect (proto: proto ? port && proto ? address && proto ? name) cfg.proto)
|
||||||
|
(proto: let portStr = toString proto.port; in
|
||||||
|
''
|
||||||
|
[${proto.name}]
|
||||||
|
enabled = ${toYesNo proto.enable}
|
||||||
|
address = ${proto.address}
|
||||||
|
port = ${toString proto.port}
|
||||||
|
${if proto ? keys then "keys = ${proto.keys}" else ""}
|
||||||
|
${if proto ? auth then "auth = ${toYesNo proto.auth}" else ""}
|
||||||
|
${if proto ? user then "user = ${proto.user}" else ""}
|
||||||
|
${if proto ? pass then "pass = ${proto.pass}" else ""}
|
||||||
|
${if proto ? outproxy then "outproxy = ${proto.outproxy}" else ""}
|
||||||
|
${if proto ? outproxyPort then "outproxyport = ${toString proto.outproxyPort}" else ""}
|
||||||
|
'')
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@ -114,7 +155,7 @@ let
|
|||||||
i2pdSh = pkgs.writeScriptBin "i2pd" ''
|
i2pdSh = pkgs.writeScriptBin "i2pd" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
${if isNull cfg.extIp then extip else ""}
|
${if isNull cfg.extIp then extip else ""}
|
||||||
${pkgs.i2pd}/bin/i2pd --log=1 \
|
${pkgs.i2pd}/bin/i2pd \
|
||||||
--host=${if isNull cfg.extIp then "$EXTIP" else cfg.extIp} \
|
--host=${if isNull cfg.extIp then "$EXTIP" else cfg.extIp} \
|
||||||
--conf=${i2pdConf} \
|
--conf=${i2pdConf} \
|
||||||
--tunconf=${i2pdTunnelConf}
|
--tunconf=${i2pdTunnelConf}
|
||||||
@ -135,6 +176,8 @@ in
|
|||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Enables I2Pd as a running service upon activation.
|
Enables I2Pd as a running service upon activation.
|
||||||
|
Please read http://i2pd.readthedocs.io/en/latest/ for further
|
||||||
|
configuration help.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -162,6 +205,22 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
netid = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 2;
|
||||||
|
description = ''
|
||||||
|
I2P overlay netid.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
bandwidth = mkOption {
|
||||||
|
type = with types; nullOr int;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Set a router bandwidth limit integer in kbps or letters: L (32), O (256), P (2048), X (>9000)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = with types; nullOr int;
|
type = with types; nullOr int;
|
||||||
default = null;
|
default = null;
|
||||||
@ -170,6 +229,14 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableIPv4 = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Enables IPv4 connectivity. Enabled by default.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
enableIPv6 = mkOption {
|
enableIPv6 = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
@ -178,16 +245,141 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
proto.http = mkEndpointOpt "http" "127.0.0.1" 7070;
|
upnp = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Enables UPnP.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "I2Pd";
|
||||||
|
description = ''
|
||||||
|
Name i2pd appears in UPnP forwardings list.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
precomputation.elgamal = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Use ElGamal precomputated tables.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
reseed = {
|
||||||
|
verify = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Request SU3 signature verification
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
file = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Full path to SU3 file to reseed from
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
urls = mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [
|
||||||
|
"https://reseed.i2p-project.de/"
|
||||||
|
"https://i2p.mooo.com/netDb/"
|
||||||
|
"https://netdb.i2p2.no/"
|
||||||
|
"https://us.reseed.i2p2.no:444/"
|
||||||
|
"https://uk.reseed.i2p2.no:444/"
|
||||||
|
"https://i2p.manas.ca:8443/"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Reseed URLs
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
addressbook = {
|
||||||
|
defaulturl = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt";
|
||||||
|
description = ''
|
||||||
|
AddressBook subscription URL for initial setup
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
subscriptions = mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [
|
||||||
|
"http://inr.i2p/export/alive-hosts.txt"
|
||||||
|
"http://i2p-projekt.i2p/hosts.txt"
|
||||||
|
"http://stats.i2p/cgi-bin/newhosts.txt"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
AddressBook subscription URLs
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
limits.transittunnels = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 2500;
|
||||||
|
description = ''
|
||||||
|
Maximum number of active transit sessions
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
proto.http = (mkEndpointOpt "http" "127.0.0.1" 7070) // {
|
||||||
|
auth = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Enable authentication for webconsole.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "i2pd";
|
||||||
|
description = ''
|
||||||
|
Username for webconsole access
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
pass = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "i2pd";
|
||||||
|
description = ''
|
||||||
|
Password for webconsole access.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
proto.httpProxy = mkKeyedEndpointOpt "httpproxy" "127.0.0.1" 4446 "";
|
||||||
|
proto.socksProxy = (mkKeyedEndpointOpt "socksproxy" "127.0.0.1" 4447 "")
|
||||||
|
// {
|
||||||
|
outproxy = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
description = "Upstream outproxy bind address.";
|
||||||
|
};
|
||||||
|
outproxyPort = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 4444;
|
||||||
|
description = "Upstream outproxy bind port.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
proto.sam = mkEndpointOpt "sam" "127.0.0.1" 7656;
|
proto.sam = mkEndpointOpt "sam" "127.0.0.1" 7656;
|
||||||
proto.bob = mkEndpointOpt "bob" "127.0.0.1" 2827;
|
proto.bob = mkEndpointOpt "bob" "127.0.0.1" 2827;
|
||||||
|
proto.i2cp = mkEndpointOpt "i2cp" "127.0.0.1" 7654;
|
||||||
proto.i2pControl = mkEndpointOpt "i2pcontrol" "127.0.0.1" 7650;
|
proto.i2pControl = mkEndpointOpt "i2pcontrol" "127.0.0.1" 7650;
|
||||||
proto.httpProxy = mkEndpointOpt "httpproxy" "127.0.0.1" 4446;
|
|
||||||
proto.socksProxy = mkEndpointOpt "socksproxy" "127.0.0.1" 4447;
|
|
||||||
|
|
||||||
outTunnels = mkOption {
|
outTunnels = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; loaOf (submodule (
|
type = with types; loaOf (submodule (
|
||||||
{ name, config, ... }: {
|
{ name, config, ... }: {
|
||||||
options = commonTunOpts name;
|
options = commonTunOpts name;
|
||||||
config = {
|
config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user