Skip to content

Commit

Permalink
Merge #406: bitcoind: one-option i2p support
Browse files Browse the repository at this point in the history
6383612 bitcoind: one-option i2p support (nixbitcoin)

Pull request description:

ACKs for top commit:
  erikarvstedt:
    ACK 6383612
  jonasnick:
    utACK 6383612

Tree-SHA512: be7806657885ba455e7137dfc8c20ea4d58898b04db030a964aafbde1c505041a1f9e700654ad9c75ab2bb9267174bdbe84c9d7e4de63a09508b72fbd5c8f1a1
  • Loading branch information
jonasnick committed Oct 15, 2021
2 parents 2250b9b + 6383612 commit 8b1b063
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions modules/bitcoind.nix
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ let
default = if cfg.enforceTor then config.nix-bitcoin.torClientAddressWithPort else null;
description = "Connect through SOCKS5 proxy";
};
i2p = mkOption {
type = types.enum [ false true "only-outgoing" ];
default = false;
description = ''
Enable peer connections via i2p.
With `only-outgoing`, incoming i2p connections are disabled.
'';
};
listen = mkOption {
type = types.bool;
default = false;
Expand Down Expand Up @@ -236,6 +244,8 @@ let
nbLib = config.nix-bitcoin.lib;
secretsDir = config.nix-bitcoin.secretsDir;

i2pSAM = config.services.i2pd.proto.sam;

configFile = builtins.toFile "bitcoin.conf" ''
# We're already logging via journald
nodebuglogfile=1
Expand All @@ -256,6 +266,9 @@ let
${optionalString cfg.listen "bind=${cfg.address}"}
port=${toString cfg.port}
${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"}
${optionalString (cfg.i2p != false) "i2psam=${nbLib.addressWithPort i2pSAM.address i2pSAM.port}"}
${optionalString (cfg.i2p == "only-outgoing") "i2pacceptincoming=0"}
listen=${if cfg.listen then "1" else "0"}
${optionalString (cfg.discover != null) "discover=${if cfg.discover then "1" else "0"}"}
${lib.concatMapStrings (node: "addnode=${node}\n") cfg.addnodes}
Expand Down Expand Up @@ -308,6 +321,11 @@ in {
}
];

services.i2pd = mkIf (cfg.i2p != false) {
enable = true;
proto.sam.enable = true;
};

systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
"d '${cfg.dataDir}/blocks' 0770 ${cfg.user} ${cfg.group} - -"
Expand Down
6 changes: 5 additions & 1 deletion modules/netns-isolation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ in {
port = 9050;
IsolateDestAddr = true;
};
networking.firewall.interfaces.nb-br.allowedTCPPorts = [ config.services.tor.client.socksListenAddress.port ];
services.i2pd.proto.sam.address = bridgeIp;
networking.firewall.interfaces.nb-br.allowedTCPPorts = [
config.services.tor.client.socksListenAddress.port
config.services.i2pd.proto.sam.port
];
boot.kernel.sysctl."net.ipv4.ip_forward" = true;

security.wrappers.netns-exec = {
Expand Down

0 comments on commit 8b1b063

Please sign in to comment.