termux-connecting 1.1.45 → 1.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  #!/data/data/com.termux/files/usr/bin/bash
2
2
  set -e
3
3
 
4
- VERSION="1.1.45"
4
+ VERSION="1.1.46"
5
5
 
6
6
  GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; CYAN='\033[0;36m'; NC='\033[0m'
7
7
  info() { echo -e "${GREEN}[✓]${NC} $1"; }
@@ -11,15 +11,37 @@ title() { echo -e "\n${CYAN}━━━ $1 ━━━${NC}\n"; }
11
11
 
12
12
  AUTO=false
13
13
  CHECK=false
14
+ MONITOR=false
15
+ HELP=false
14
16
  DEBUG=false
15
17
  for arg in "$@"; do
16
18
  [ "$arg" = "-y" ] && AUTO=true
17
19
  [ "$arg" = "--check" ] || [ "$arg" = "--status" ] && CHECK=true
20
+ [ "$arg" = "--monitor" ] && MONITOR=true
21
+ [ "$arg" = "--help" ] || [ "$arg" = "-h" ] && HELP=true
18
22
  [ "$arg" = "--debug" ] && DEBUG=true
19
23
  done
20
24
 
21
25
  $DEBUG && set -x
22
26
 
27
+ if $HELP; then
28
+ echo ""
29
+ title "TERMUX CONNECTING v${VERSION} — Bantuan"
30
+ echo " Penggunaan: termux-connecting [opsi]"
31
+ echo ""
32
+ echo " Opsi:"
33
+ echo " (tanpa opsi) Jalankan setup interaktif"
34
+ echo " -y Setup otomatis (skip konfirmasi)"
35
+ echo " --check, --status Tampilkan status SSH & jaringan"
36
+ echo " --monitor Mode realtime monitoring (auto-restart sshd)"
37
+ echo " --help, -h Tampilkan bantuan ini"
38
+ echo " --debug Aktifkan tracing (set -x)"
39
+ echo ""
40
+ echo " Subcommand (PC): termux-connect-pc --help"
41
+ echo ""
42
+ exit 0
43
+ fi
44
+
23
45
  # ─── Mode: Check/Status ───
24
46
  if $CHECK; then
25
47
  echo ""
@@ -78,6 +100,70 @@ if $CHECK; then
78
100
  exit 0
79
101
  fi
80
102
 
103
+ # ─── Mode: Monitor ───
104
+ monitor_loop() {
105
+ local version="$VERSION"
106
+ local interval=5
107
+
108
+ echo ""
109
+ info "Mode monitoring aktif. Ketik 'exit' untuk keluar."
110
+ sleep 1
111
+
112
+ set +e
113
+ while true; do
114
+ local now=$(date '+%H:%M:%S')
115
+ local uptime_str=$(uptime -p 2>/dev/null | sed 's/^up //')
116
+ local ip=""
117
+ local sshd_pid=""
118
+
119
+ for iface in wlan0 eth0; do
120
+ ip=$(timeout 2 ip -4 addr show $iface 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1)
121
+ [ -n "$ip" ] && break
122
+ done
123
+ if [ -z "$ip" ]; then
124
+ ip=$(timeout 2 ip route get 1.1.1.1 2>/dev/null | awk '{print $7}')
125
+ fi
126
+ ip="${ip:-❌ Tidak ada IP}"
127
+
128
+ if pgrep -x sshd >/dev/null; then
129
+ sshd_pid=$(pgrep -x sshd | head -1)
130
+ local sshd_uptime=$(ps -o etime= -p "$sshd_pid" 2>/dev/null | xargs)
131
+ local sshd_label="${sshd_pid} (${sshd_uptime})"
132
+ else
133
+ sshd_label="❌ Mati — restart..."
134
+ sshd 2>/dev/null
135
+ fi
136
+
137
+ local connections=$(ss -tnp 2>/dev/null | grep -c ':8022.*ESTAB' 2>/dev/null || echo 0)
138
+
139
+ clear 2>/dev/null || printf "\033c"
140
+ echo ""
141
+ echo " ╔══════════════════════════════════════════╗"
142
+ echo " ║ TERMUX CONNECTING — MONITOR v${VERSION} ║"
143
+ echo " ╠══════════════════════════════════════════╣"
144
+ printf " ║ ⏱ %-36s ║\n" "Waktu : $now"
145
+ printf " ║ ⏱ %-36s ║\n$([[ "$uptime_str" != "" ]] && echo " ║ Uptime : $uptime_str")"
146
+ printf " ║ 🔑 %-36s ║\n" "SSHD PID : $sshd_label"
147
+ printf " ║ 🌐 %-36s ║\n$([[ "$ip" != "" ]] && echo " ║ IP : $ip")"
148
+ printf " ║ 🔗 %-36s ║\n" "Koneksi : $connections aktif"
149
+ echo " ╠══════════════════════════════════════════╣"
150
+ echo " ║ Ketik 'exit' lalu Enter untuk keluar ║"
151
+ echo " ╚══════════════════════════════════════════╝"
152
+
153
+ read -t "$interval" input
154
+ [ "$input" = "exit" ] && break
155
+ done
156
+
157
+ echo ""
158
+ info "Monitoring dihentikan"
159
+ set -e
160
+ }
161
+
162
+ if $MONITOR; then
163
+ monitor_loop
164
+ exit 0
165
+ fi
166
+
81
167
  confirm() {
82
168
  local msg="$1" default="$2"
83
169
  $AUTO && return 0
@@ -105,14 +191,19 @@ if [ ! -f "$WELCOME_FILE" ]; then
105
191
  echo -e "${CYAN}Di PC/Mac, jalankan:${NC}"
106
192
  echo " termux-connect-pc"
107
193
  echo ""
194
+ echo -e "${CYAN}Opsi termux-connecting (HP):${NC}"
195
+ echo " termux-connecting Setup interaktif"
196
+ echo " termux-connecting -y Setup otomatis (skip konfirmasi)"
197
+ echo " termux-connecting --check Cek status SSH & jaringan"
198
+ echo " termux-connecting --monitor Realtime monitoring + auto-restart"
199
+ echo " termux-connecting --help Bantuan"
200
+ echo ""
108
201
  echo -e "${CYAN}Subcommand PC:${NC}"
109
202
  echo " termux-connect-pc connection Setup/ubah koneksi"
110
203
  echo " termux-connect-pc check Cek koneksi & kirim alert Telegram"
111
204
  echo " termux-connect-pc help Bantuan"
112
205
  echo " termux-connect-pc version Versi"
113
206
  echo ""
114
- echo -e "${YELLOW}Gunakan -y untuk skip semua konfirmasi: termux-connecting -y${NC}"
115
- echo ""
116
207
  mkdir -p "$HOME/.config/termux-connecting"
117
208
  touch "$WELCOME_FILE"
118
209
  fi
@@ -305,6 +396,7 @@ if [ "$AUTO" = "false" ]; then
305
396
  echo " 3) Status SSH server"
306
397
  echo " 4) Tampilkan ulang info koneksi"
307
398
  echo " 5) Cek permission & fitur"
399
+ echo " 6) Realtime monitoring"
308
400
  echo ""
309
401
  echo -n " Pilih [1]: "
310
402
  read -r post_choice
@@ -339,9 +431,9 @@ if [ "$AUTO" = "false" ]; then
339
431
  command -v termux-wake-lock >/dev/null 2>&1 && HAS_WAKE="yes"
340
432
  title "Status Permission & Fitur"
341
433
  echo " ┌─────────────────────────────────────────────┐"
342
- [ "$HAS_STORAGE" = "yes" ] && echo " │ Storage — akses penyimpanan │" || echo " │ Storage — akses penyimpanan │"
343
- [ "$HAS_BOOT" = "yes" ] && echo " │ ✅ Termux:Boot — auto-start sshd │" || echo " │ ❌ Termux:Boot — auto-start sshd │"
344
- [ "$HAS_WAKE" = "yes" ] && echo " │ ✅ Wake lock — koneksi tetap saat mati layar │" || echo " │ ❌ Wake lock — koneksi tetap saat mati layar "
434
+ echo " │ ✅ Storage — akses penyimpanan │" | sed "s/✅/$([ "$HAS_STORAGE" = "yes" ] && echo '' || echo '')/"
435
+ echo " │ ✅ Termux:Boot — auto-start sshd │" | sed "s/✅/$([ "$HAS_BOOT" = "yes" ] && echo '✅' || echo '❌')/"
436
+ echo " │ ✅ Wake lock — koneksi tetap saat mati layar │" | sed "s/✅/$([ "$HAS_WAKE" = "yes" ] && echo '✅' || echo '❌')/"
345
437
  echo " └─────────────────────────────────────────────┘"
346
438
  echo ""
347
439
  if [ "$HAS_STORAGE" = "no" ] && confirm " Setup storage permission" "y"; then termux-setup-storage; echo " Izininkan pop-up permission di Android"; echo ""; fi
@@ -349,6 +441,7 @@ if [ "$AUTO" = "false" ]; then
349
441
  if [ "$HAS_BOOT" = "no" ] && confirm " Setup auto-start sshd (Termux:Boot)" "y"; then mkdir -p "$HOME/.termux/boot"; echo 'sshd' > "$HOME/.termux/boot/boot-sshd"; chmod +x "$HOME/.termux/boot/boot-sshd"; info "Boot script: ~/.termux/boot/boot-sshd"; echo " https://f-droid.org/packages/com.termux.boot/"; echo " Reboot HP agar sshd jalan otomatis"; echo ""; fi
350
442
  [ "$HAS_WAKE" = "yes" ] && termux-wake-lock 2>/dev/null && info "Wake lock aktif"
351
443
  ;;
444
+ 6) monitor_loop ;;
352
445
  *) break ;;
353
446
  esac
354
447
  done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termux-connecting",
3
- "version": "1.1.45",
3
+ "version": "1.1.46",
4
4
  "description": "CLI setup Termux + koneksi SSH dari PC/Mac dengan Telegram alert",
5
5
  "bin": {
6
6
  "termux-connecting": "bin/termux-connecting",