🛠️ chore: update scripts and documentation for v1.1.3 release

This commit is contained in:
rE-Bo0t.bx1
2025-12-05 20:24:55 +08:00
parent ca517d1768
commit 49c9f69918
7 changed files with 9 additions and 125 deletions

View File

@@ -6,9 +6,8 @@ PT_STATE_DIR="${TOR_DATA_DIR}/pt_state"
BRIDGE_LINE_FILE="${PT_STATE_DIR}/obfs4_bridgeline.txt"
TORRC_FILE="${TOR_CONFIG:-/etc/tor/torrc}"
# Check if we're running as a bridge
if [ -f "$TORRC_FILE" ] && grep -q "^BridgeRelay 1" "$TORRC_FILE" 2>/dev/null; then
: # Bridge mode confirmed
:
elif [ -f "$TORRC_FILE" ]; then
echo ""
echo "❌ Not a bridge relay"
@@ -26,7 +25,6 @@ else
exit 1
fi
# Check for bridge line file
if [ -f "$BRIDGE_LINE_FILE" ]; then
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@@ -53,7 +51,6 @@ if [ -f "$BRIDGE_LINE_FILE" ]; then
exit 0
fi
# Bridge line not available yet
echo ""
echo "⏳ Bridge line not available yet"
echo ""
@@ -74,7 +71,6 @@ echo " 4. Verify bridge config:"
echo " docker exec <container> grep BridgeRelay $TORRC_FILE"
echo ""
# Try to find bridge line in logs as fallback
if [ -f "/var/log/tor/notices.log" ]; then
if grep -q "bridge line" /var/log/tor/notices.log 2>/dev/null; then
echo "📝 Found in logs:"

View File

@@ -10,7 +10,6 @@ if [ -f "$FINGERPRINT_FILE" ]; then
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Read and format fingerprint
NICKNAME=$(cat "$FINGERPRINT_FILE" | awk '{print $1}')
FINGERPRINT=$(cat "$FINGERPRINT_FILE" | awk '{print $2}')
@@ -18,11 +17,9 @@ if [ -f "$FINGERPRINT_FILE" ]; then
echo " 🔐 Fingerprint: $FINGERPRINT"
echo ""
# Format for easy copying
echo " 📋 Copy/paste: $NICKNAME $FINGERPRINT"
echo ""
# Show search URL
echo " 🔍 Find on Tor Metrics:"
echo " https://metrics.torproject.org/rs.html#search/$FINGERPRINT"
echo ""

View File

@@ -4,25 +4,21 @@
TOR_LOG="${TOR_LOG_DIR:-/var/log/tor}/notices.log"
TOR_DATA="${TOR_DATA_DIR:-/var/lib/tor}"
# Sanitize numeric values to prevent "bad number" errors
sanitize_num() {
v=$(printf '%s' "$1" | tr -cd '0-9')
[ -z "$v" ] && v=0
printf '%s' "$v"
}
# Check if running
if ! pgrep -x tor >/dev/null 2>&1; then
echo '{"status":"down","bootstrap":0,"reachable":"unknown","errors":0}'
exit 1
fi
# Get PID and uptime
TOR_PID=$(pgrep -x tor)
TOR_PID=$(sanitize_num "$TOR_PID")
UPTIME=$(ps -o etime= -p "$TOR_PID" 2>/dev/null | tr -d ' ' || echo "unknown")
# Check bootstrap
BOOTSTRAP=0
if [ -f "$TOR_LOG" ]; then
if grep -q "Bootstrapped 100%" "$TOR_LOG"; then
@@ -33,7 +29,6 @@ if [ -f "$TOR_LOG" ]; then
fi
BOOTSTRAP=$(sanitize_num "$BOOTSTRAP")
# Check reachability
REACHABLE="unknown"
if [ -f "$TOR_LOG" ]; then
if grep -q "Self-testing indicates your ORPort is reachable" "$TOR_LOG"; then
@@ -43,11 +38,9 @@ if [ -f "$TOR_LOG" ]; then
fi
fi
# Count errors
ERRORS=$(grep -c "\[err\]" "$TOR_LOG" 2>/dev/null || echo "0")
ERRORS=$(sanitize_num "$ERRORS")
# Get nickname and fingerprint
NICKNAME="unknown"
FINGERPRINT="unknown"
if [ -f "$TOR_DATA/fingerprint" ]; then
@@ -55,7 +48,6 @@ if [ -f "$TOR_DATA/fingerprint" ]; then
FINGERPRINT=$(cat "$TOR_DATA/fingerprint" | awk '{print $2}')
fi
# Output comprehensive JSON
cat <<EOF
{
"status": "up",

View File

@@ -4,21 +4,18 @@
TOR_LOG="${TOR_LOG_DIR:-/var/log/tor}/notices.log"
TOR_DATA="${TOR_DATA_DIR:-/var/lib/tor}"
# Sanitize numeric values to prevent "bad number" errors
sanitize_num() {
v=$(printf '%s' "$1" | tr -cd '0-9')
[ -z "$v" ] && v=0
printf '%s' "$v"
}
# Header
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🧅 Tor Relay Status"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Check if Tor is running
if pgrep -x tor >/dev/null 2>&1; then
TOR_PID=$(pgrep -x tor)
echo "🚀 Status: RUNNING (PID: $TOR_PID)"
@@ -28,14 +25,12 @@ else
exit 1
fi
# Check log file
if [ ! -f "$TOR_LOG" ]; then
echo "⚠️ Log: NOT FOUND"
echo ""
exit 1
fi
# Bootstrap progress
if grep -q "Bootstrapped 100%" "$TOR_LOG" 2>/dev/null; then
echo "✅ Bootstrap: 100% COMPLETE"
else
@@ -44,7 +39,6 @@ else
echo "⏳ Bootstrap: ${PROGRESS}%"
fi
# Reachability
if grep -q "Self-testing indicates your ORPort is reachable" "$TOR_LOG"; then
echo "🌐 ORPort: REACHABLE"
elif grep -q "ORPort is not reachable" "$TOR_LOG"; then
@@ -53,19 +47,16 @@ else
echo "❓ ORPort: TESTING..."
fi
# Get relay info (POSIX-compliant fingerprint truncation)
if [ -f "$TOR_DATA/fingerprint" ] && [ -r "$TOR_DATA/fingerprint" ]; then
FINGERPRINT=$(cat "$TOR_DATA/fingerprint" | awk '{print $2}')
NICKNAME=$(cat "$TOR_DATA/fingerprint" | awk '{print $1}')
echo "🪪 Nickname: $NICKNAME"
# POSIX-compliant substring extraction using cut
FP_START=$(printf "%s" "$FINGERPRINT" | cut -c1-8)
FP_END=$(printf "%s" "$FINGERPRINT" | cut -c33-40)
echo "🔑 Fingerprint: ${FP_START}...${FP_END}"
fi
# Count errors and warnings
ERRORS=$(grep -c "\[err\]" "$TOR_LOG" 2>/dev/null || echo "0")
ERRORS=$(sanitize_num "$ERRORS")
WARNINGS=$(grep -c "\[warn\]" "$TOR_LOG" 2>/dev/null || echo "0")
@@ -81,7 +72,6 @@ if [ "$WARNINGS" -gt 5 ]; then
echo "⚠️ Warnings: $WARNINGS"
fi
# Uptime
UPTIME=$(ps -o etime= -p "$TOR_PID" 2>/dev/null | tr -d ' ' || echo "unknown")
[ -n "$UPTIME" ] && echo "⏱️ Uptime: $UPTIME"