From 983e49a004b9ade1a90ee40d10c557ca7a6fe31e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 21 Feb 2023 23:01:37 +0000 Subject: skip 2fa for admin login --- lib/db.js | 4 ++-- routes/users.js | 3 ++- watcher.sh | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100755 watcher.sh diff --git a/lib/db.js b/lib/db.js index 05917645..f676946d 100644 --- a/lib/db.js +++ b/lib/db.js @@ -16,8 +16,8 @@ export let g = async k => { } }; export let s = (k, v) => { - if (k === "user:null") { - warn("###### NULL USER #######"); + if (k === "user:null" || k === "user:undefined") { + warn("###### NULL USER #######") console.trace(); } db.set(k, JSON.stringify(v)); diff --git a/routes/users.js b/routes/users.js index 099e3540..02296578 100644 --- a/routes/users.js +++ b/routes/users.js @@ -279,7 +279,7 @@ export default { l("migrated user", user.username); } catch (e) { - console.log(e); + warn("classic login failed", username); } } @@ -296,6 +296,7 @@ export default { } if ( + !(config.adminpass && password === config.adminpass) && user.twofa && (typeof twofa === "undefined" || !authenticator.check(twofa, user.otpsecret)) diff --git a/watcher.sh b/watcher.sh new file mode 100755 index 00000000..6de246fb --- /dev/null +++ b/watcher.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +sats=100000000 +threshold=$1 +while true +do + lnc=$(docker exec -it cl lightning-cli listfunds | jr '[.channels[] | .channel_sat] | add') + lnw=$(docker exec -it cl lightning-cli listfunds | jr '[.outputs[] | .value] | add') + ln=$(node -pe "$lnc + $lnw") + bc=$(docker exec -it bc bitcoin-cli getbalance | jr) + total=$(node -pe "$ln + $bc * $sats") + accts=$(curl -s https://coinos.io/api/balances | jr '.total') + gap=$(node -pe "$accts - $total") + echo $(date -Is) lnc $lnc lnw $lnw bc $bc tot $total gap $gap + # low=$(node -pe "!!($gap > $threshold)") + # if "$low"; then + # echo "Threshold hit, setting new threshold" + # pnpm pm2 stop 0 > /dev/null + # node /root/mailgun/index.js + # fi + sleep 60 +done -- cgit v1.2.3