termux-connecting 1.1.45 → 1.1.47

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.47"
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" ] || [ "$arg" = "--monitoring" ] && 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 ""
@@ -38,7 +60,7 @@ if $CHECK; then
38
60
  fi
39
61
  echo ""
40
62
  echo " 🌐 Network :"
41
- for iface in wlan0 eth0; do
63
+ for iface in wlan0 wlan1 eth0 eth1 wlp2s0 wlp3s0 en0 en1; do
42
64
  addr=$(timeout 2 ip -4 addr show $iface 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1)
43
65
  if [ -n "$addr" ]; then
44
66
  echo " $iface : $addr"
@@ -78,6 +100,76 @@ 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 wlan1 eth0 eth1 wlp2s0 wlp3s0 en0 en1; 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
+ if [ -z "$ip" ] && command -v ifconfig >/dev/null; then
127
+ ip=$(timeout 2 ifconfig 2>/dev/null | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
128
+ fi
129
+ if [ -z "$ip" ]; then
130
+ ip=$(timeout 2 ip -4 addr show 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -1)
131
+ fi
132
+ ip="${ip:-❌ Tidak ada IP}"
133
+
134
+ if pgrep -x sshd >/dev/null; then
135
+ sshd_pid=$(pgrep -x sshd | head -1)
136
+ local sshd_uptime=$(ps -o etime= -p "$sshd_pid" 2>/dev/null | xargs)
137
+ local sshd_label="${sshd_pid} (${sshd_uptime})"
138
+ else
139
+ sshd_label="❌ Mati — restart..."
140
+ sshd 2>/dev/null
141
+ fi
142
+
143
+ local connections=$(ss -tnp 2>/dev/null | grep -c ':8022.*ESTAB' 2>/dev/null || echo 0)
144
+
145
+ clear 2>/dev/null || printf "\033c"
146
+ echo ""
147
+ echo " ╔══════════════════════════════════════════╗"
148
+ echo " ║ TERMUX CONNECTING — MONITOR v${VERSION} ║"
149
+ echo " ╠══════════════════════════════════════════╣"
150
+ printf " ║ ⏱ %-36s ║\n" "Waktu : $now"
151
+ printf " ║ ⏱ %-36s ║\n$([[ "$uptime_str" != "" ]] && echo " ║ Uptime : $uptime_str")"
152
+ printf " ║ 🔑 %-36s ║\n" "SSHD PID : $sshd_label"
153
+ printf " ║ 🌐 %-36s ║\n$([[ "$ip" != "" ]] && echo " ║ IP : $ip")"
154
+ printf " ║ 🔗 %-36s ║\n" "Koneksi : $connections aktif"
155
+ echo " ╠══════════════════════════════════════════╣"
156
+ echo " ║ Ketik 'exit' lalu Enter untuk keluar ║"
157
+ echo " ╚══════════════════════════════════════════╝"
158
+
159
+ read -t "$interval" input
160
+ [ "$input" = "exit" ] && break
161
+ done
162
+
163
+ echo ""
164
+ info "Monitoring dihentikan"
165
+ set -e
166
+ }
167
+
168
+ if $MONITOR; then
169
+ monitor_loop
170
+ exit 0
171
+ fi
172
+
81
173
  confirm() {
82
174
  local msg="$1" default="$2"
83
175
  $AUTO && return 0
@@ -105,14 +197,19 @@ if [ ! -f "$WELCOME_FILE" ]; then
105
197
  echo -e "${CYAN}Di PC/Mac, jalankan:${NC}"
106
198
  echo " termux-connect-pc"
107
199
  echo ""
200
+ echo -e "${CYAN}Opsi termux-connecting (HP):${NC}"
201
+ echo " termux-connecting Setup interaktif"
202
+ echo " termux-connecting -y Setup otomatis (skip konfirmasi)"
203
+ echo " termux-connecting --check Cek status SSH & jaringan"
204
+ echo " termux-connecting --monitor Realtime monitoring + auto-restart"
205
+ echo " termux-connecting --help Bantuan"
206
+ echo ""
108
207
  echo -e "${CYAN}Subcommand PC:${NC}"
109
208
  echo " termux-connect-pc connection Setup/ubah koneksi"
110
209
  echo " termux-connect-pc check Cek koneksi & kirim alert Telegram"
111
210
  echo " termux-connect-pc help Bantuan"
112
211
  echo " termux-connect-pc version Versi"
113
212
  echo ""
114
- echo -e "${YELLOW}Gunakan -y untuk skip semua konfirmasi: termux-connecting -y${NC}"
115
- echo ""
116
213
  mkdir -p "$HOME/.config/termux-connecting"
117
214
  touch "$WELCOME_FILE"
118
215
  fi
@@ -305,6 +402,7 @@ if [ "$AUTO" = "false" ]; then
305
402
  echo " 3) Status SSH server"
306
403
  echo " 4) Tampilkan ulang info koneksi"
307
404
  echo " 5) Cek permission & fitur"
405
+ echo " 6) Realtime monitoring"
308
406
  echo ""
309
407
  echo -n " Pilih [1]: "
310
408
  read -r post_choice
@@ -339,9 +437,9 @@ if [ "$AUTO" = "false" ]; then
339
437
  command -v termux-wake-lock >/dev/null 2>&1 && HAS_WAKE="yes"
340
438
  title "Status Permission & Fitur"
341
439
  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 "
440
+ echo " │ ✅ Storage — akses penyimpanan │" | sed "s/✅/$([ "$HAS_STORAGE" = "yes" ] && echo '' || echo '')/"
441
+ echo " │ ✅ Termux:Boot — auto-start sshd │" | sed "s/✅/$([ "$HAS_BOOT" = "yes" ] && echo '✅' || echo '❌')/"
442
+ echo " │ ✅ Wake lock — koneksi tetap saat mati layar │" | sed "s/✅/$([ "$HAS_WAKE" = "yes" ] && echo '✅' || echo '❌')/"
345
443
  echo " └─────────────────────────────────────────────┘"
346
444
  echo ""
347
445
  if [ "$HAS_STORAGE" = "no" ] && confirm " Setup storage permission" "y"; then termux-setup-storage; echo " Izininkan pop-up permission di Android"; echo ""; fi
@@ -349,6 +447,7 @@ if [ "$AUTO" = "false" ]; then
349
447
  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
448
  [ "$HAS_WAKE" = "yes" ] && termux-wake-lock 2>/dev/null && info "Wake lock aktif"
351
449
  ;;
450
+ 6) monitor_loop ;;
352
451
  *) break ;;
353
452
  esac
354
453
  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.47",
4
4
  "description": "CLI setup Termux + koneksi SSH dari PC/Mac dengan Telegram alert",
5
5
  "bin": {
6
6
  "termux-connecting": "bin/termux-connecting",