From 6c44fe94ee0dcf9b38a7fed8d8cfd18d187b4632 Mon Sep 17 00:00:00 2001 From: qedk <1994constant@gmail.com> Date: Thu, 30 Nov 2023 17:45:14 +0400 Subject: [PATCH] feat: read randomness from /dev/urandom --- .gitignore | 2 ++ availup.sh | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b3f7fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +identity.toml diff --git a/availup.sh b/availup.sh index 20b7e44..729db7c 100755 --- a/availup.sh +++ b/availup.sh @@ -49,7 +49,12 @@ if [ -z "$config" ]; then echo "ℹī¸ No config file selected. Defaulting to $HOME/.avail/$NETWORK/config.yml." CONFIG="$HOME/.avail/$NETWORK/config.yml" touch $CONFIG - SEED=$(hexdump -vn32 -e'8/8 "%0X"' /dev/urandom) + if command -v hexdump >/dev/null 2>&1; then + echo "🔐 Generating random seed..." + SEED=$(hexdump -vn32 -e'8/8 "%0X"' /dev/urandom) + else + SEED="$RANDOM$RANDOM-avail-$RANDOM$RANDOM" + fi if [ "$NETWORK" = "goldberg" ]; then echo "log_level = \"info\"\nhttp_server_host = \"0.0.0.0\"\nhttp_server_port = 7001\n\nsecret_key = { seed = \"$SEED\" }\nlibp2p_port = \"37000\"\nfull_node_ws = [\"wss://goldberg.avail.tools:443/ws\"]\napp_id = $APPID\nconfidence = 99.0\navail_path = \"$HOME/.avail-light/$NETWORK\"\nbootstraps = [[\"12D3KooWBkLsNGaD3SpMaRWtAmWVuiZg1afdNSPbtJ8M8r9ArGRT\",\"/dns/bootnode.1.lightclient.goldberg.avail.tools/udp/37000/quic-v1\"]]" >~/.avail/$NETWORK/config.yml elif [ "$NETWORK" = "kate" ]; then