2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.i2pd;
|
|
|
|
|
|
|
|
homeDir = "/var/lib/i2pd";
|
|
|
|
|
|
|
|
strOpt = k: v: k + " = " + v;
|
|
|
|
boolOpt = k: v: k + " = " + boolToString v;
|
|
|
|
intOpt = k: v: k + " = " + toString v;
|
|
|
|
lstOpt = k: xs: k + " = " + concatStringsSep "," xs;
|
|
|
|
optionalNullString = o: s: optional (s != null) (strOpt o s);
|
|
|
|
optionalNullBool = o: b: optional (b != null) (boolOpt o b);
|
|
|
|
optionalNullInt = o: i: optional (i != null) (intOpt o i);
|
|
|
|
optionalEmptyList = o: l: optional ([] != l) (lstOpt o l);
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
mkEnableTrueOption = name: mkEnableOption name // { default = true; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
mkEndpointOpt = name: addr: port: {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption name;
|
2020-04-24 23:36:52 +00:00
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The endpoint name.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = addr;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Bind address for ${name} endpoint.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
port = mkOption {
|
2021-08-11 14:56:57 +00:00
|
|
|
type = types.port;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = port;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Bind port for ${name} endpoint.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
i2cpOpts = name: {
|
|
|
|
length = mkOption {
|
|
|
|
type = types.int;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Guaranteed minimum hops for ${name} tunnels.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 3;
|
|
|
|
};
|
|
|
|
quantity = mkOption {
|
|
|
|
type = types.int;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Number of simultaneous ${name} tunnels.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 5;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
mkKeyedEndpointOpt = name: addr: port: keyloc:
|
|
|
|
(mkEndpointOpt name addr port) // {
|
|
|
|
keys = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = keyloc;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
File to persist ${lib.toUpper name} keys.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
inbound = i2cpOpts name;
|
|
|
|
outbound = i2cpOpts name;
|
|
|
|
latency.min = mkOption {
|
|
|
|
type = with types; nullOr int;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Min latency for tunnels.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
latency.max = mkOption {
|
|
|
|
type = with types; nullOr int;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Max latency for tunnels.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
commonTunOpts = name: {
|
|
|
|
outbound = i2cpOpts name;
|
|
|
|
inbound = i2cpOpts name;
|
|
|
|
crypto.tagsToSend = mkOption {
|
|
|
|
type = types.int;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Number of ElGamal/AES tags to send.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 40;
|
|
|
|
};
|
|
|
|
destination = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Remote endpoint, I2P hostname or b32.i2p address.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
keys = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name + "-keys.dat";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Keyset used for tunnel identity.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
} // mkEndpointOpt name "127.0.0.1" 0;
|
|
|
|
|
|
|
|
sec = name: "\n[" + name + "]";
|
|
|
|
notice = "# DO NOT EDIT -- this file has been generated automatically.";
|
|
|
|
i2pdConf = let
|
|
|
|
opts = [
|
|
|
|
notice
|
|
|
|
(strOpt "loglevel" cfg.logLevel)
|
|
|
|
(boolOpt "logclftime" cfg.logCLFTime)
|
|
|
|
(boolOpt "ipv4" cfg.enableIPv4)
|
|
|
|
(boolOpt "ipv6" cfg.enableIPv6)
|
|
|
|
(boolOpt "notransit" cfg.notransit)
|
|
|
|
(boolOpt "floodfill" cfg.floodfill)
|
|
|
|
(intOpt "netid" cfg.netid)
|
|
|
|
] ++ (optionalNullInt "bandwidth" cfg.bandwidth)
|
|
|
|
++ (optionalNullInt "port" cfg.port)
|
|
|
|
++ (optionalNullString "family" cfg.family)
|
|
|
|
++ (optionalNullString "datadir" cfg.dataDir)
|
|
|
|
++ (optionalNullInt "share" cfg.share)
|
|
|
|
++ (optionalNullBool "ssu" cfg.ssu)
|
|
|
|
++ (optionalNullBool "ntcp" cfg.ntcp)
|
|
|
|
++ (optionalNullString "ntcpproxy" cfg.ntcpProxy)
|
|
|
|
++ (optionalNullString "ifname" cfg.ifname)
|
|
|
|
++ (optionalNullString "ifname4" cfg.ifname4)
|
|
|
|
++ (optionalNullString "ifname6" cfg.ifname6)
|
|
|
|
++ [
|
|
|
|
(sec "limits")
|
|
|
|
(intOpt "transittunnels" cfg.limits.transittunnels)
|
|
|
|
(intOpt "coresize" cfg.limits.coreSize)
|
|
|
|
(intOpt "openfiles" cfg.limits.openFiles)
|
|
|
|
(intOpt "ntcphard" cfg.limits.ntcpHard)
|
|
|
|
(intOpt "ntcpsoft" cfg.limits.ntcpSoft)
|
|
|
|
(intOpt "ntcpthreads" cfg.limits.ntcpThreads)
|
|
|
|
(sec "upnp")
|
|
|
|
(boolOpt "enabled" cfg.upnp.enable)
|
|
|
|
(sec "precomputation")
|
|
|
|
(boolOpt "elgamal" cfg.precomputation.elgamal)
|
|
|
|
(sec "reseed")
|
|
|
|
(boolOpt "verify" cfg.reseed.verify)
|
|
|
|
] ++ (optionalNullString "file" cfg.reseed.file)
|
|
|
|
++ (optionalEmptyList "urls" cfg.reseed.urls)
|
|
|
|
++ (optionalNullString "floodfill" cfg.reseed.floodfill)
|
|
|
|
++ (optionalNullString "zipfile" cfg.reseed.zipfile)
|
|
|
|
++ (optionalNullString "proxy" cfg.reseed.proxy)
|
|
|
|
++ [
|
|
|
|
(sec "trust")
|
|
|
|
(boolOpt "enabled" cfg.trust.enable)
|
|
|
|
(boolOpt "hidden" cfg.trust.hidden)
|
|
|
|
] ++ (optionalEmptyList "routers" cfg.trust.routers)
|
|
|
|
++ (optionalNullString "family" cfg.trust.family)
|
|
|
|
++ [
|
|
|
|
(sec "websockets")
|
|
|
|
(boolOpt "enabled" cfg.websocket.enable)
|
|
|
|
(strOpt "address" cfg.websocket.address)
|
|
|
|
(intOpt "port" cfg.websocket.port)
|
|
|
|
(sec "exploratory")
|
|
|
|
(intOpt "inbound.length" cfg.exploratory.inbound.length)
|
|
|
|
(intOpt "inbound.quantity" cfg.exploratory.inbound.quantity)
|
|
|
|
(intOpt "outbound.length" cfg.exploratory.outbound.length)
|
|
|
|
(intOpt "outbound.quantity" cfg.exploratory.outbound.quantity)
|
|
|
|
(sec "ntcp2")
|
|
|
|
(boolOpt "enabled" cfg.ntcp2.enable)
|
|
|
|
(boolOpt "published" cfg.ntcp2.published)
|
|
|
|
(intOpt "port" cfg.ntcp2.port)
|
|
|
|
(sec "addressbook")
|
|
|
|
(strOpt "defaulturl" cfg.addressbook.defaulturl)
|
|
|
|
] ++ (optionalEmptyList "subscriptions" cfg.addressbook.subscriptions)
|
2022-07-14 12:49:19 +00:00
|
|
|
++ [
|
|
|
|
(sec "meshnets")
|
|
|
|
(boolOpt "yggdrasil" cfg.yggdrasil.enable)
|
|
|
|
] ++ (optionalNullString "yggaddress" cfg.yggdrasil.address)
|
2020-04-24 23:36:52 +00:00
|
|
|
++ (flip map
|
|
|
|
(collect (proto: proto ? port && proto ? address) cfg.proto)
|
|
|
|
(proto: let protoOpts = [
|
|
|
|
(sec proto.name)
|
|
|
|
(boolOpt "enabled" proto.enable)
|
|
|
|
(strOpt "address" proto.address)
|
|
|
|
(intOpt "port" proto.port)
|
2023-07-15 17:15:38 +00:00
|
|
|
] ++ (optionals (proto ? keys) (optionalNullString "keys" proto.keys))
|
|
|
|
++ (optionals (proto ? auth) (optionalNullBool "auth" proto.auth))
|
|
|
|
++ (optionals (proto ? user) (optionalNullString "user" proto.user))
|
|
|
|
++ (optionals (proto ? pass) (optionalNullString "pass" proto.pass))
|
|
|
|
++ (optionals (proto ? strictHeaders) (optionalNullBool "strictheaders" proto.strictHeaders))
|
|
|
|
++ (optionals (proto ? hostname) (optionalNullString "hostname" proto.hostname))
|
|
|
|
++ (optionals (proto ? outproxy) (optionalNullString "outproxy" proto.outproxy))
|
|
|
|
++ (optionals (proto ? outproxyPort) (optionalNullInt "outproxyport" proto.outproxyPort))
|
|
|
|
++ (optionals (proto ? outproxyEnable) (optionalNullBool "outproxy.enabled" proto.outproxyEnable));
|
2020-04-24 23:36:52 +00:00
|
|
|
in (concatStringsSep "\n" protoOpts)
|
|
|
|
));
|
|
|
|
in
|
|
|
|
pkgs.writeText "i2pd.conf" (concatStringsSep "\n" opts);
|
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
tunnelConf = let
|
|
|
|
mkOutTunnel = tun:
|
|
|
|
let
|
|
|
|
outTunOpts = [
|
|
|
|
(sec tun.name)
|
|
|
|
"type = client"
|
|
|
|
(intOpt "port" tun.port)
|
|
|
|
(strOpt "destination" tun.destination)
|
2023-07-15 17:15:38 +00:00
|
|
|
] ++ (optionals (tun ? destinationPort) (optionalNullInt "destinationport" tun.destinationPort))
|
2024-07-31 10:19:44 +00:00
|
|
|
++ (optionals (tun ? keys) (optionalNullString "keys" tun.keys))
|
|
|
|
++ (optionals (tun ? address) (optionalNullString "address" tun.address))
|
|
|
|
++ (optionals (tun ? inbound.length) (optionalNullInt "inbound.length" tun.inbound.length))
|
|
|
|
++ (optionals (tun ? inbound.quantity) (optionalNullInt "inbound.quantity" tun.inbound.quantity))
|
|
|
|
++ (optionals (tun ? outbound.length) (optionalNullInt "outbound.length" tun.outbound.length))
|
|
|
|
++ (optionals (tun ? outbound.quantity) (optionalNullInt "outbound.quantity" tun.outbound.quantity))
|
|
|
|
++ (optionals (tun ? crypto.tagsToSend) (optionalNullInt "crypto.tagstosend" tun.crypto.tagsToSend));
|
|
|
|
in
|
|
|
|
concatStringsSep "\n" outTunOpts;
|
|
|
|
|
|
|
|
mkInTunnel = tun:
|
|
|
|
let
|
|
|
|
inTunOpts = [
|
|
|
|
(sec tun.name)
|
|
|
|
"type = server"
|
|
|
|
(intOpt "port" tun.port)
|
|
|
|
(strOpt "host" tun.address)
|
|
|
|
] ++ (optionals (tun ? destination) (optionalNullString "destination" tun.destination))
|
|
|
|
++ (optionals (tun ? keys) (optionalNullString "keys" tun.keys))
|
|
|
|
++ (optionals (tun ? inPort) (optionalNullInt "inport" tun.inPort))
|
|
|
|
++ (optionals (tun ? accessList) (optionalEmptyList "accesslist" tun.accessList));
|
|
|
|
in
|
|
|
|
concatStringsSep "\n" inTunOpts;
|
|
|
|
|
|
|
|
allOutTunnels = collect (tun: tun ? port && tun ? destination) cfg.outTunnels;
|
|
|
|
allInTunnels = collect (tun: tun ? port && tun ? address) cfg.inTunnels;
|
|
|
|
|
|
|
|
opts = [ notice ] ++ (map mkOutTunnel allOutTunnels) ++ (map mkInTunnel allInTunnels);
|
|
|
|
in
|
|
|
|
pkgs.writeText "i2pd-tunnels.conf" (concatStringsSep "\n" opts);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
i2pdFlags = concatStringsSep " " (
|
|
|
|
optional (cfg.address != null) ("--host=" + cfg.address) ++ [
|
|
|
|
"--service"
|
|
|
|
("--conf=" + i2pdConf)
|
|
|
|
("--tunconf=" + tunnelConf)
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "i2pd" "extIp" ] [ "services" "i2pd" "address" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.i2pd = {
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "I2Pd daemon" // {
|
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enables I2Pd as a running service upon activation.
|
2023-11-16 04:20:00 +00:00
|
|
|
Please read <https://i2pd.readthedocs.io/en/latest/> for further
|
2020-04-24 23:36:52 +00:00
|
|
|
configuration help.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "i2pd" { };
|
2022-01-03 16:56:52 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
logLevel = mkOption {
|
|
|
|
type = types.enum ["debug" "info" "warn" "error"];
|
|
|
|
default = "error";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
The log level. {command}`i2pd` defaults to "info"
|
2020-04-24 23:36:52 +00:00
|
|
|
but that generates copious amounts of log messages.
|
|
|
|
|
|
|
|
We default to "error" which is similar to the default log
|
2022-08-12 12:06:08 +00:00
|
|
|
level of {command}`tor`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
logCLFTime = mkEnableOption "full CLF-formatted date and time to log";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Your external IP or hostname.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
family = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Specify a family the router belongs to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Alternative path to storage of i2pd data (RI, keys, peer profiles, ...)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
share = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 100;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Limit of transit traffic from max bandwidth in percents.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ifname = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Network interface to bind to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ifname4 = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
IPv4 interface to bind to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ifname6 = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
IPv6 interface to bind to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ntcpProxy = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Proxy URL for NTCP transport.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ntcp = mkEnableTrueOption "ntcp";
|
|
|
|
ssu = mkEnableTrueOption "ssu";
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
notransit = mkEnableOption "notransit" // {
|
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Tells the router to not accept transit tunnels during startup.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
floodfill = mkEnableOption "floodfill" // {
|
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
If the router is declared to be unreachable and needs introduction nodes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
netid = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 2;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
I2P overlay netid.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bandwidth = mkOption {
|
|
|
|
type = with types; nullOr int;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Set a router bandwidth limit integer in KBps.
|
2022-08-12 12:06:08 +00:00
|
|
|
If not set, {command}`i2pd` defaults to 32KBps.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = with types; nullOr int;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
I2P listen port. If no one is given the router will pick between 9111 and 30777.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableIPv4 = mkEnableTrueOption "IPv4 connectivity";
|
2024-04-21 15:54:59 +00:00
|
|
|
enableIPv6 = mkEnableOption "IPv6 connectivity";
|
2020-04-24 23:36:52 +00:00
|
|
|
nat = mkEnableTrueOption "NAT bypass";
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
upnp.enable = mkEnableOption "UPnP service discovery";
|
2020-04-24 23:36:52 +00:00
|
|
|
upnp.name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "I2Pd";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Name i2pd appears in UPnP forwardings list.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
precomputation.elgamal = mkEnableTrueOption "Precomputed ElGamal tables" // {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whenever to use precomputated tables for ElGamal.
|
2022-09-11 15:47:08 +00:00
|
|
|
{command}`i2pd` defaults to `false`
|
2020-04-24 23:36:52 +00:00
|
|
|
to save 64M of memory (and looses some performance).
|
|
|
|
|
2022-09-11 15:47:08 +00:00
|
|
|
We default to `true` as that is what most
|
2020-04-24 23:36:52 +00:00
|
|
|
users want anyway.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
reseed.verify = mkEnableOption "SU3 signature verification";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
reseed.file = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Full path to SU3 file to reseed from.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
reseed.urls = mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Reseed URLs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
reseed.floodfill = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Path to router info of floodfill to reseed from.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
reseed.zipfile = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Path to local .zip file to reseed from.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
reseed.proxy = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
URL for reseed proxy, supports http/socks.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
addressbook.defaulturl = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
AddressBook subscription URL for initial setup
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
addressbook.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"
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
AddressBook subscription URLs
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
trust.enable = mkEnableOption "explicit trust options";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
trust.family = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-12-28 21:21:41 +00:00
|
|
|
Router Family to trust for first hops.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
trust.routers = mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Only connect to the listed routers.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
trust.hidden = mkEnableOption "router concealment";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
websocket = mkEndpointOpt "websockets" "127.0.0.1" 7666;
|
|
|
|
|
|
|
|
exploratory.inbound = i2cpOpts "exploratory";
|
|
|
|
exploratory.outbound = i2cpOpts "exploratory";
|
|
|
|
|
2021-10-06 13:57:05 +00:00
|
|
|
ntcp2.enable = mkEnableTrueOption "NTCP2";
|
2024-04-21 15:54:59 +00:00
|
|
|
ntcp2.published = mkEnableOption "NTCP2 publication";
|
2020-04-24 23:36:52 +00:00
|
|
|
ntcp2.port = mkOption {
|
2022-12-17 10:02:37 +00:00
|
|
|
type = types.port;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Port to listen for incoming NTCP2 connections (0=auto).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
limits.transittunnels = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 2500;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Maximum number of active transit sessions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
limits.coreSize = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Maximum size of corefile in Kb (0 - use system limit).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
limits.openFiles = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Maximum number of open files (0 - use system default).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
limits.ntcpHard = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Maximum number of active transit sessions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
limits.ntcpSoft = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Threshold to start probabalistic backoff with ntcp sessions (default: use system limit).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
limits.ntcpThreads = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 1;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Maximum number of threads used by NTCP DH worker.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
yggdrasil.enable = mkEnableOption "Yggdrasil";
|
2022-07-14 12:49:19 +00:00
|
|
|
|
|
|
|
yggdrasil.address = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-07-14 12:49:19 +00:00
|
|
|
Your local yggdrasil address. Specify it if you want to bind your router to a
|
|
|
|
particular address.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
proto.http = (mkEndpointOpt "http" "127.0.0.1" 7070) // {
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
auth = mkEnableOption "webconsole authentication";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "i2pd";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Username for webconsole access
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
pass = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "i2pd";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Password for webconsole access.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
strictHeaders = mkOption {
|
|
|
|
type = with types; nullOr bool;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enable strict host checking on WebUI.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hostname = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Expected hostname for WebUI.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
proto.httpProxy = (mkKeyedEndpointOpt "httpproxy" "127.0.0.1" 4444 "httpproxy-keys.dat")
|
|
|
|
// {
|
|
|
|
outproxy = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Upstream outproxy bind address.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
proto.socksProxy = (mkKeyedEndpointOpt "socksproxy" "127.0.0.1" 4447 "socksproxy-keys.dat")
|
|
|
|
// {
|
2024-04-21 15:54:59 +00:00
|
|
|
outproxyEnable = mkEnableOption "SOCKS outproxy";
|
2020-04-24 23:36:52 +00:00
|
|
|
outproxy = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Upstream outproxy bind address.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
outproxyPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 4444;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Upstream outproxy bind port.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
proto.sam = mkEndpointOpt "sam" "127.0.0.1" 7656;
|
|
|
|
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;
|
|
|
|
|
|
|
|
outTunnels = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = with types; attrsOf (submodule (
|
|
|
|
{ name, ... }: {
|
|
|
|
options = {
|
|
|
|
destinationPort = mkOption {
|
|
|
|
type = with types; nullOr int;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Connect to particular port at destination.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
} // commonTunOpts name;
|
|
|
|
config = {
|
|
|
|
name = mkDefault name;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
));
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Connect to someone as a client and establish a local accept endpoint
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
inTunnels = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = with types; attrsOf (submodule (
|
|
|
|
{ name, ... }: {
|
|
|
|
options = {
|
|
|
|
inPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Service port. Default to the tunnel's listen port.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
accessList = mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "I2P nodes that are allowed to connect to this service.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
} // commonTunOpts name;
|
|
|
|
config = {
|
|
|
|
name = mkDefault name;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
));
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Serve something on I2P network at port and delegate requests to address inPort.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.users.i2pd = {
|
|
|
|
group = "i2pd";
|
|
|
|
description = "I2Pd User";
|
|
|
|
home = homeDir;
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.i2pd;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.i2pd.gid = config.ids.gids.i2pd;
|
|
|
|
|
|
|
|
systemd.services.i2pd = {
|
|
|
|
description = "Minimal I2P router";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig =
|
|
|
|
{
|
|
|
|
User = "i2pd";
|
|
|
|
WorkingDirectory = homeDir;
|
|
|
|
Restart = "on-abort";
|
2022-02-10 20:34:41 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/i2pd ${i2pdFlags}";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|