From d750de876c409ae8d4a13db6ea37766fb073815e Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Wed, 10 Apr 2024 17:12:40 -0400 Subject: [PATCH] multi: add script to connect to nodes in flagship dockerfile --- README.md | 2 ++ setup/Dockerfile | 3 +++ setup/connect_nodes.sh | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 setup/connect_nodes.sh diff --git a/README.md b/README.md index 2653b80..3c9b684 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,8 @@ The following utilities are available for your convenience: * `source ./lncli.sh` provides aliases for your LND nodes (`lncli0`, `lncli1`, `lncli2`) * `./fund.sh` funds each of your LND nodes. +* `./connect_nodes.sh` connects the attacking nodes to the network + so that they can sync gossip. * `bitcoin-cli` provides access to the bitcoin node that all three LND nodes are connected to. diff --git a/setup/Dockerfile b/setup/Dockerfile index 881aacb..050b0ea 100644 --- a/setup/Dockerfile +++ b/setup/Dockerfile @@ -41,5 +41,8 @@ COPY lncli.sh /lncli.sh COPY fund.sh /fund.sh RUN chmod +x fund.sh +COPY connect_nodes.sh /connect_nodes.sh +RUN chmod +x connect_nodes.sh + # Set entrypoint to just sleep indefinitely - attackers will run their own scripts. ENTRYPOINT ["bash", "-c", "while true; do sleep 30; done;"] diff --git a/setup/connect_nodes.sh b/setup/connect_nodes.sh new file mode 100644 index 0000000..9f12ba1 --- /dev/null +++ b/setup/connect_nodes.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Path to the nodes.txt file +nodes_file="credentials/nodes.txt" + +# Check if nodes.txt exists +if [ ! -f "$nodes_file" ]; then + echo "Error: nodes.txt file not found." + exit 1 +fi + +lncli0="lncli --network=regtest --tlscertpath=/credentials/lnd0-tls.cert --macaroonpath=/credentials/lnd0-admin.macaroon --rpcserver=lightning-0.warnet-armada " +lncli1="lncli --network=regtest --tlscertpath=/credentials/lnd1-tls.cert --macaroonpath=/credentials/lnd1-admin.macaroon --rpcserver=lightning-1.warnet-armada " +lncli2="lncli --network=regtest --tlscertpath=/credentials/lnd2-tls.cert --macaroonpath=/credentials/lnd2-admin.macaroon --rpcserver=lightning-2.warnet-armada " + +# Iterate through each line in nodes.txt +while IFS= read -r line; do + echo "Connecting nodes to $line" + # Call lncli connect with the extracted string + $lncli0 connect "$line" + $lncli1 connect "$line" + $lncli2 connect "$line" +done < "$nodes_file"