5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-09 23:00:26 +00:00

Connect all mappers to each other.

This commit is contained in:
Vanhala Antti 2014-05-13 17:03:14 +03:00
parent b97ad55ddc
commit d62a3289e7

View File

@ -3,6 +3,20 @@
source conf_sh.py source conf_sh.py
mkdir -p mapper-confs mkdir -p mapper-confs
# Generate configurations and collect their publick keys and ports
for i in $(seq 1 $num_of_nodes)
do
file=mapper-confs/node$i.conf
$cjdns_path/cjdroute --genconf > $file
# Get connecting info
publicKey=$(grep -oP -m1 '(?<="publicKey": ").*(?=",)' $file)
connectPort=$(grep -oP -m1 '(?<="0.0.0.0:).*(?=",)' $file)
connectToInfo[i]='"127.0.0.1:'"$connectPort"'":{"password":"'"$rpc_pw"'","publicKey":"'"$publicKey"'"},'
done
# Modify configurations
for i in $(seq 1 $num_of_nodes) for i in $(seq 1 $num_of_nodes)
do do
echo "Starting mapper node $i/$num_of_nodes" echo "Starting mapper node $i/$num_of_nodes"
@ -10,10 +24,18 @@ do
file=mapper-confs/node$i.conf file=mapper-confs/node$i.conf
rpcport=$(($rpc_firstport + $i - 1)) rpcport=$(($rpc_firstport + $i - 1))
$cjdns_path/cjdroute --genconf > $file # Connect to all mapper nodes except itself
connectInfo=""
for j in $(seq 1 $num_of_nodes)
do
if [[ $i != $j ]]; then
connectInfo+="${connectToInfo[j]}"
fi
done
# Set peer credentials # Set peer credentials
sed -i 's/\/\/ Add connection credentials here to join the network/"'"${peer_ip}"':'"${peer_port}"'":{"password":"'"${peer_pw}"'","publicKey":"'"${peer_pk}"'"}/g' $file sed -i 's/\/\/ Add connection credentials here to join the network/'"$connectInfo"'/g' $file
sed -i 's/\/\/ Ask somebody who is already connected./"'"${peer_ip}"':'"${peer_port}"'":{"password":"'"${peer_pw}"'","publicKey":"'"${peer_pk}"'"}/g' $file
# Set admin rpc credentials # Set admin rpc credentials
sed -i 's/127.0.0.1:11234/'"${rpc_bind}"':'"${rpcport}"'/g' $file sed -i 's/127.0.0.1:11234/'"${rpc_bind}"':'"${rpcport}"'/g' $file
@ -22,6 +44,7 @@ do
# Disable tun interface # Disable tun interface
sed -i 's/"type": "TUNInterface"/\/\/"type": "TUNInterface"/g' $file sed -i 's/"type": "TUNInterface"/\/\/"type": "TUNInterface"/g' $file
# Start mappers
if [[ $* == *-d* ]]; then if [[ $* == *-d* ]]; then
# Log to stdout # Log to stdout
sed -i 's/\/\/ "logTo":"stdout"/"logTo":"stdout"/g' $file sed -i 's/\/\/ "logTo":"stdout"/"logTo":"stdout"/g' $file