termux-connecting 1.1.47 → 1.1.49
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.
- package/bin/termux-connecting +44 -31
- package/package.json +1 -1
package/bin/termux-connecting
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/data/data/com.termux/files/usr/bin/bash
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
VERSION="1.1.
|
|
4
|
+
VERSION="1.1.49"
|
|
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"; }
|
|
@@ -9,6 +9,36 @@ warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
|
|
9
9
|
error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
10
10
|
title() { echo -e "\n${CYAN}━━━ $1 ━━━${NC}\n"; }
|
|
11
11
|
|
|
12
|
+
# ─── Helper: dapatkan IP dengan berbagai metode ───
|
|
13
|
+
get_ip() {
|
|
14
|
+
local ip=""
|
|
15
|
+
if command -v ip >/dev/null; then
|
|
16
|
+
for iface in wlan0 wlan1 eth0 eth1 wlp2s0 wlp3s0 en0 en1; do
|
|
17
|
+
ip=$(timeout 2 ip -4 addr show $iface 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1)
|
|
18
|
+
[ -n "$ip" ] && break
|
|
19
|
+
done
|
|
20
|
+
if [ -z "$ip" ]; then
|
|
21
|
+
ip=$(timeout 2 ip route get 1.1.1.1 2>/dev/null | awk '{print $7}')
|
|
22
|
+
fi
|
|
23
|
+
if [ -z "$ip" ]; then
|
|
24
|
+
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)
|
|
25
|
+
fi
|
|
26
|
+
fi
|
|
27
|
+
if [ -z "$ip" ] && command -v ifconfig >/dev/null; then
|
|
28
|
+
ip=$(timeout 2 ifconfig 2>/dev/null | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
|
|
29
|
+
fi
|
|
30
|
+
if [ -z "$ip" ] && command -v getprop >/dev/null; then
|
|
31
|
+
local iface=$(getprop wifi.interface)
|
|
32
|
+
[ -n "$iface" ] && ip=$(getprop dhcp.${iface}.ipaddress 2>/dev/null)
|
|
33
|
+
[ -z "$ip" ] && ip=$(getprop dhcp.wlan0.ipaddress 2>/dev/null)
|
|
34
|
+
[ -z "$ip" ] && ip=$(getprop dhcp.wlan1.ipaddress 2>/dev/null)
|
|
35
|
+
fi
|
|
36
|
+
if [ -z "$ip" ] && [ -f /proc/net/fib_trie ]; then
|
|
37
|
+
ip=$(awk '/32 host/ { print parent } /LOCAL/ { print parent } { parent = $2 }' /proc/net/fib_trie 2>/dev/null | grep -v "LOOPBACK" | head -1)
|
|
38
|
+
fi
|
|
39
|
+
echo "$ip"
|
|
40
|
+
}
|
|
41
|
+
|
|
12
42
|
AUTO=false
|
|
13
43
|
CHECK=false
|
|
14
44
|
MONITOR=false
|
|
@@ -66,7 +96,8 @@ if $CHECK; then
|
|
|
66
96
|
echo " $iface : $addr"
|
|
67
97
|
fi
|
|
68
98
|
done
|
|
69
|
-
|
|
99
|
+
any_ip=$(get_ip)
|
|
100
|
+
if [ -z "$any_ip" ]; then
|
|
70
101
|
echo " ❌ Tidak ada IP (nonaktif/data)"
|
|
71
102
|
fi
|
|
72
103
|
echo ""
|
|
@@ -116,19 +147,7 @@ monitor_loop() {
|
|
|
116
147
|
local ip=""
|
|
117
148
|
local sshd_pid=""
|
|
118
149
|
|
|
119
|
-
|
|
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
|
|
150
|
+
local ip=$(get_ip)
|
|
132
151
|
ip="${ip:-❌ Tidak ada IP}"
|
|
133
152
|
|
|
134
153
|
if pgrep -x sshd >/dev/null; then
|
|
@@ -216,13 +235,19 @@ fi
|
|
|
216
235
|
|
|
217
236
|
title "TERMUX CONNECTING v${VERSION} — Setup"
|
|
218
237
|
|
|
219
|
-
# ─── 1. coreutils ───
|
|
238
|
+
# ─── 1. coreutils & iproute2 ───
|
|
220
239
|
if ! command -v timeout >/dev/null; then
|
|
221
240
|
echo " Dibutuhkan: coreutils (untuk timeout)"
|
|
222
241
|
if confirm "Install coreutils" "y"; then
|
|
223
242
|
pkg install -y coreutils
|
|
224
243
|
fi
|
|
225
244
|
fi
|
|
245
|
+
if ! command -v ip >/dev/null; then
|
|
246
|
+
echo " Dibutuhkan: iproute2 (untuk deteksi IP)"
|
|
247
|
+
if confirm "Install iproute2" "y"; then
|
|
248
|
+
pkg install -y iproute2
|
|
249
|
+
fi
|
|
250
|
+
fi
|
|
226
251
|
|
|
227
252
|
# ─── 2. Update & Upgrade ───
|
|
228
253
|
title "1. Update & Upgrade Paket"
|
|
@@ -321,19 +346,7 @@ echo ""
|
|
|
321
346
|
title "5. Informasi Koneksi"
|
|
322
347
|
USERNAME=$(whoami)
|
|
323
348
|
|
|
324
|
-
IP
|
|
325
|
-
if command -v ip >/dev/null; then
|
|
326
|
-
IP=$(timeout 3 ip -4 addr show 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -1)
|
|
327
|
-
fi
|
|
328
|
-
if [ -z "$IP" ] && command -v ifconfig >/dev/null; then
|
|
329
|
-
IP=$(timeout 3 ifconfig 2>/dev/null | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
|
|
330
|
-
fi
|
|
331
|
-
if [ -z "$IP" ] && [ -d /data/data/com.termux ]; then
|
|
332
|
-
IP=$(timeout 3 ip route get 1.1.1.1 2>/dev/null | awk '{print $7}' | head -1)
|
|
333
|
-
fi
|
|
334
|
-
if [ -z "$IP" ]; then
|
|
335
|
-
IP=""
|
|
336
|
-
fi
|
|
349
|
+
IP=$(get_ip)
|
|
337
350
|
|
|
338
351
|
is_cgnat() {
|
|
339
352
|
[[ "$1" =~ ^10\. ]] || [[ "$1" =~ ^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\. ]]
|
|
@@ -365,7 +378,7 @@ elif is_cgnat "$IP"; then
|
|
|
365
378
|
echo " 2. Buka Pengaturan → WiFi, hubungkan ke jaringan yang sama dengan PC"
|
|
366
379
|
echo " 3. Catat IP yang muncul (biasanya 192.168.x.x)"
|
|
367
380
|
echo " 4. Jalankan ulang: termux-connecting -y"
|
|
368
|
-
echo " 5. Atau cek IP manual: ip a | grep wlan"
|
|
381
|
+
echo " 5. Atau cek IP manual: ip a | grep wlan (atau: ifconfig, atau: getprop dhcp.wlan0.ipaddress)"
|
|
369
382
|
elif is_wifi "$IP"; then
|
|
370
383
|
CONNECTION_OK=true
|
|
371
384
|
echo " Di PC/Mac:"
|
|
@@ -383,7 +396,7 @@ else
|
|
|
383
396
|
warn "IP ${IP} tidak dikenal — mungkin bukan jaringan lokal"
|
|
384
397
|
echo " Pastikan HP terhubung ke WiFi, bukan data seluler."
|
|
385
398
|
echo ""
|
|
386
|
-
echo " Cek koneksi WiFi: ip a
|
|
399
|
+
echo " Cek koneksi WiFi: ip a (atau: ifconfig, getprop dhcp.wlan0.ipaddress)"
|
|
387
400
|
echo " Jika IP masih ${IP}, mungkin HP menggunakan VPN/proxy."
|
|
388
401
|
echo " Matikan VPN dan coba lagi: termux-connecting -y"
|
|
389
402
|
fi
|