Format the bash script
This commit is contained in:
parent
8ad02453a7
commit
087d6fbc55
1 changed files with 2499 additions and 2495 deletions
|
|
@ -29,7 +29,6 @@ NONCE_LOG_FILE="$DATA_DIR/run/nonces_$$"
|
||||||
AUTO_LISTEN_FLAG="$DATA_DIR/run/autolisten_$$"
|
AUTO_LISTEN_FLAG="$DATA_DIR/run/autolisten_$$"
|
||||||
AUTO_LISTEN_PID=""
|
AUTO_LISTEN_PID=""
|
||||||
|
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
LISTEN_PORT=7777
|
LISTEN_PORT=7777
|
||||||
TOR_SOCKS_PORT=9050
|
TOR_SOCKS_PORT=9050
|
||||||
|
|
@ -450,15 +449,12 @@ install_snowflake() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
start_tor() {
|
start_tor() {
|
||||||
if [ -n "$TOR_PID" ] && kill -0 "$TOR_PID" 2>/dev/null; then
|
if [ -n "$TOR_PID" ] && kill -0 "$TOR_PID" 2>/dev/null; then
|
||||||
log_info "Tor is already running (PID $TOR_PID)"
|
log_info "Tor is already running (PID $TOR_PID)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
setup_tor
|
setup_tor
|
||||||
|
|
||||||
# Clear old log so we only see fresh output
|
# Clear old log so we only see fresh output
|
||||||
|
|
@ -642,8 +638,8 @@ get_circuit_hops() {
|
||||||
|
|
||||||
# Find best BUILT circuit — prefer HS circuits
|
# Find best BUILT circuit — prefer HS circuits
|
||||||
local circuit_line
|
local circuit_line
|
||||||
circuit_line=$(echo "$circ_resp" | grep " BUILT " \
|
circuit_line=$(echo "$circ_resp" | grep " BUILT " |
|
||||||
| grep -E "PURPOSE=HS_SERVICE_INTRO|PURPOSE=HS_CLIENT_REND" | head -1) || true
|
grep -E "PURPOSE=HS_SERVICE_INTRO|PURPOSE=HS_CLIENT_REND" | head -1) || true
|
||||||
[ -z "$circuit_line" ] && circuit_line=$(echo "$circ_resp" | grep " BUILT " | head -1)
|
[ -z "$circuit_line" ] && circuit_line=$(echo "$circ_resp" | grep " BUILT " | head -1)
|
||||||
[ -z "$circuit_line" ] && return 1
|
[ -z "$circuit_line" ] && return 1
|
||||||
|
|
||||||
|
|
@ -658,9 +654,11 @@ get_circuit_hops() {
|
||||||
for r in "${relays[@]}"; do
|
for r in "${relays[@]}"; do
|
||||||
local name fp
|
local name fp
|
||||||
if [[ "$r" == *"~"* ]]; then
|
if [[ "$r" == *"~"* ]]; then
|
||||||
name="${r#*~}"; fp="${r%%~*}"
|
name="${r#*~}"
|
||||||
|
fp="${r%%~*}"
|
||||||
else
|
else
|
||||||
name="${r:0:8}..."; fp="$r"
|
name="${r:0:8}..."
|
||||||
|
fp="$r"
|
||||||
fi
|
fi
|
||||||
names+=("$name")
|
names+=("$name")
|
||||||
fps+=("${fp#\$}")
|
fps+=("${fp#\$}")
|
||||||
|
|
@ -774,7 +772,6 @@ set_shared_secret() {
|
||||||
log_ok "Shared secret saved"
|
log_ok "Shared secret saved"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Encrypt a file
|
# Encrypt a file
|
||||||
encrypt_file() {
|
encrypt_file() {
|
||||||
local infile="$1" outfile="$2"
|
local infile="$1" outfile="$2"
|
||||||
|
|
@ -1012,25 +1009,21 @@ audio_play() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Play an opus file
|
# Play an opus file
|
||||||
play_chunk() {
|
play_chunk() {
|
||||||
local opus_file="$1"
|
local opus_file="$1"
|
||||||
|
|
||||||
if [ $IS_TERMUX -eq 1 ]; then
|
if [ $IS_TERMUX -eq 1 ]; then
|
||||||
# Termux: pipe decode directly to sox play (avoids temp file + Android media framework)
|
# Termux: pipe decode directly to sox play (avoids temp file + Android media framework)
|
||||||
opusdec --quiet --rate 48000 "$opus_file" - 2>/dev/null | \
|
opusdec --quiet --rate 48000 "$opus_file" - 2>/dev/null |
|
||||||
play -q -t raw -r 48000 -e signed -b 16 -c 1 - 2>/dev/null || true
|
play -q -t raw -r 48000 -e signed -b 16 -c 1 - 2>/dev/null || true
|
||||||
else
|
else
|
||||||
# Linux: pipe decode directly to aplay
|
# Linux: pipe decode directly to aplay
|
||||||
opusdec --quiet --rate 48000 "$opus_file" - 2>/dev/null | \
|
opusdec --quiet --rate 48000 "$opus_file" - 2>/dev/null |
|
||||||
aplay -f S16_LE -r 48000 -c 1 -q 2>/dev/null || true
|
aplay -f S16_LE -r 48000 -c 1 -q 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# CALL CLEANUP — RESET EVERYTHING TO FRESH STATE
|
# CALL CLEANUP — RESET EVERYTHING TO FRESH STATE
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
@ -1161,9 +1154,9 @@ start_vol_monitor() {
|
||||||
|
|
||||||
while [ -f "$CONNECTED_FLAG" ]; do
|
while [ -f "$CONNECTED_FLAG" ]; do
|
||||||
local cur_vol
|
local cur_vol
|
||||||
cur_vol=$(termux-volume 2>/dev/null \
|
cur_vol=$(termux-volume 2>/dev/null |
|
||||||
| jq -r '.[] | select(.stream=="music") | .volume' 2>/dev/null \
|
jq -r '.[] | select(.stream=="music") | .volume' 2>/dev/null ||
|
||||||
|| echo "")
|
echo "")
|
||||||
|
|
||||||
# Remember the initial volume so we can restore after detection
|
# Remember the initial volume so we can restore after detection
|
||||||
if [ -n "$cur_vol" ] && [ -z "$restore_vol" ]; then
|
if [ -n "$cur_vol" ] && [ -z "$restore_vol" ]; then
|
||||||
|
|
@ -1424,8 +1417,10 @@ draw_call_header() {
|
||||||
# Snowflake bridge info
|
# Snowflake bridge info
|
||||||
if [ "$SNOWFLAKE_ENABLED" -eq 1 ]; then
|
if [ "$SNOWFLAKE_ENABLED" -eq 1 ]; then
|
||||||
local tor_log="$TOR_DIR/tor.log"
|
local tor_log="$TOR_DIR/tor.log"
|
||||||
echo "" >&2; _r=$((_r + 1))
|
echo "" >&2
|
||||||
echo -e " ${TOR_PURPLE}●${NC} ${BOLD}Snowflake bridge${NC}" >&2; _r=$((_r + 1))
|
_r=$((_r + 1))
|
||||||
|
echo -e " ${TOR_PURPLE}●${NC} ${BOLD}Snowflake bridge${NC}" >&2
|
||||||
|
_r=$((_r + 1))
|
||||||
if [ -f "$tor_log" ]; then
|
if [ -f "$tor_log" ]; then
|
||||||
local bridge_line=""
|
local bridge_line=""
|
||||||
bridge_line=$(grep "new bridge descriptor" "$tor_log" 2>/dev/null | tail -1 || true)
|
bridge_line=$(grep "new bridge descriptor" "$tor_log" 2>/dev/null | tail -1 || true)
|
||||||
|
|
@ -1463,8 +1458,10 @@ draw_call_header() {
|
||||||
local _hop_data
|
local _hop_data
|
||||||
_hop_data=$(get_circuit_hops 2>/dev/null) || true
|
_hop_data=$(get_circuit_hops 2>/dev/null) || true
|
||||||
if [ -n "$_hop_data" ]; then
|
if [ -n "$_hop_data" ]; then
|
||||||
echo "" >&2; _r=$((_r + 1))
|
echo "" >&2
|
||||||
echo -e " ${TOR_PURPLE}●${NC} ${BOLD}Circuit${NC}" >&2; _r=$((_r + 1))
|
_r=$((_r + 1))
|
||||||
|
echo -e " ${TOR_PURPLE}●${NC} ${BOLD}Circuit${NC}" >&2
|
||||||
|
_r=$((_r + 1))
|
||||||
CIRCUIT_START_ROW=$_r
|
CIRCUIT_START_ROW=$_r
|
||||||
local _hop_i=0 _hop_total
|
local _hop_i=0 _hop_total
|
||||||
_hop_total=$(echo "$_hop_data" | wc -l)
|
_hop_total=$(echo "$_hop_data" | wc -l)
|
||||||
|
|
@ -1480,7 +1477,8 @@ draw_call_header() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "" >&2; _r=$((_r + 1))
|
echo "" >&2
|
||||||
|
_r=$((_r + 1))
|
||||||
|
|
||||||
# Static placeholders — updated in-place via ANSI positioning
|
# Static placeholders — updated in-place via ANSI positioning
|
||||||
echo -e " ${DIM}Last sent: --${NC}" >&2
|
echo -e " ${DIM}Last sent: --${NC}" >&2
|
||||||
|
|
@ -1491,7 +1489,8 @@ draw_call_header() {
|
||||||
RECV_INFO_ROW=$_r
|
RECV_INFO_ROW=$_r
|
||||||
_r=$((_r + 1))
|
_r=$((_r + 1))
|
||||||
|
|
||||||
echo "" >&2; _r=$((_r + 1))
|
echo "" >&2
|
||||||
|
_r=$((_r + 1))
|
||||||
|
|
||||||
# Static status bar
|
# Static status bar
|
||||||
if [ $IS_TERMUX -eq 1 ]; then
|
if [ $IS_TERMUX -eq 1 ]; then
|
||||||
|
|
@ -1765,7 +1764,8 @@ in_call_session() {
|
||||||
# TERMUX: Toggle mode
|
# TERMUX: Toggle mode
|
||||||
if [ $ptt_active -eq 0 ]; then
|
if [ $ptt_active -eq 0 ]; then
|
||||||
ptt_active=1
|
ptt_active=1
|
||||||
printf '\033[s' >&2; printf '\033[%d;1H\033[K' "$STATUS_ROW" >&2
|
printf '\033[s' >&2
|
||||||
|
printf '\033[%d;1H\033[K' "$STATUS_ROW" >&2
|
||||||
printf ' \033[41;1;37m \u25cf RECORDING \033[0m \033[2m[SPACE]=Send\033[0m ' >&2
|
printf ' \033[41;1;37m \u25cf RECORDING \033[0m \033[2m[SPACE]=Send\033[0m ' >&2
|
||||||
printf '\033[u' >&2
|
printf '\033[u' >&2
|
||||||
start_recording
|
start_recording
|
||||||
|
|
@ -1785,7 +1785,8 @@ in_call_session() {
|
||||||
# LINUX: Hold-to-talk
|
# LINUX: Hold-to-talk
|
||||||
if [ $ptt_active -eq 0 ]; then
|
if [ $ptt_active -eq 0 ]; then
|
||||||
ptt_active=1
|
ptt_active=1
|
||||||
printf '\033[s' >&2; printf '\033[%d;1H\033[K' "$STATUS_ROW" >&2
|
printf '\033[s' >&2
|
||||||
|
printf '\033[%d;1H\033[K' "$STATUS_ROW" >&2
|
||||||
printf ' \033[41;1;37;5m \u25cf RECORDING \033[0m ' >&2
|
printf ' \033[41;1;37;5m \u25cf RECORDING \033[0m ' >&2
|
||||||
printf '\033[u' >&2
|
printf '\033[u' >&2
|
||||||
stty time 5 # longer timeout to span keyboard repeat delay
|
stty time 5 # longer timeout to span keyboard repeat delay
|
||||||
|
|
@ -2251,8 +2252,7 @@ settings_cipher() {
|
||||||
0 | q | Q)
|
0 | q | Q)
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
'')
|
'') ;;
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
if [[ "$cinput" =~ ^[0-9]+$ ]] && [ "$cinput" -ge 1 ] && [ "$cinput" -le "$total" ]; then
|
if [[ "$cinput" =~ ^[0-9]+$ ]] && [ "$cinput" -ge 1 ] && [ "$cinput" -le "$total" ]; then
|
||||||
local selected="${ciphers[$((cinput - 1))]}"
|
local selected="${ciphers[$((cinput - 1))]}"
|
||||||
|
|
@ -2451,7 +2451,8 @@ settings_voice() {
|
||||||
4) VOICE_EFFECT="robot" ;;
|
4) VOICE_EFFECT="robot" ;;
|
||||||
5) VOICE_EFFECT="echo" ;;
|
5) VOICE_EFFECT="echo" ;;
|
||||||
6) VOICE_EFFECT="whisper" ;;
|
6) VOICE_EFFECT="whisper" ;;
|
||||||
7) VOICE_EFFECT="custom"
|
7)
|
||||||
|
VOICE_EFFECT="custom"
|
||||||
settings_voice_custom
|
settings_voice_custom
|
||||||
;;
|
;;
|
||||||
0 | q | Q) return ;;
|
0 | q | Q) return ;;
|
||||||
|
|
@ -2960,15 +2961,18 @@ main_menu() {
|
||||||
read -r
|
read -r
|
||||||
;;
|
;;
|
||||||
4) set_shared_secret ;;
|
4) set_shared_secret ;;
|
||||||
5) test_audio
|
5)
|
||||||
|
test_audio
|
||||||
echo -ne " ${DIM}Press Enter to continue...${NC}"
|
echo -ne " ${DIM}Press Enter to continue...${NC}"
|
||||||
read -r
|
read -r
|
||||||
;;
|
;;
|
||||||
6) show_status
|
6)
|
||||||
|
show_status
|
||||||
echo -ne " ${DIM}Press Enter to continue...${NC}"
|
echo -ne " ${DIM}Press Enter to continue...${NC}"
|
||||||
read -r
|
read -r
|
||||||
;;
|
;;
|
||||||
7) install_deps
|
7)
|
||||||
|
install_deps
|
||||||
echo -ne "\n ${DIM}Press Enter to continue...${NC}"
|
echo -ne "\n ${DIM}Press Enter to continue...${NC}"
|
||||||
read -r
|
read -r
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue