termux-connecting 1.1.54 → 1.1.55
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-connect-pc +5 -4
- package/bin/termux-connecting +23 -11
- package/package.json +1 -1
package/bin/termux-connect-pc
CHANGED
|
@@ -99,9 +99,10 @@ cmd_connection() {
|
|
|
99
99
|
|
|
100
100
|
if [ -n "$new_name" ]; then
|
|
101
101
|
HOST_ALIAS="$new_name"
|
|
102
|
+
load_config "$new_name" || true
|
|
102
103
|
fi
|
|
103
104
|
|
|
104
|
-
title "TERMUX
|
|
105
|
+
title "TERMUX CONNECTING v${VERSION} — Connection Setup"
|
|
105
106
|
echo "Saya akan bantu kamu menghubungkan PC ini ke Termux di HP."
|
|
106
107
|
echo ""
|
|
107
108
|
|
|
@@ -163,7 +164,7 @@ cmd_connection() {
|
|
|
163
164
|
echo " ── Cek Ping ke $SSH_HOST ──"
|
|
164
165
|
echo " Ping $SSH_HOST untuk verifikasi..."
|
|
165
166
|
if command -v ping >/dev/null; then
|
|
166
|
-
result=$(
|
|
167
|
+
result=$(run_timeout 5 ping -c 2 -W 2 "$SSH_HOST" 2>&1)
|
|
167
168
|
loss=$(echo "$result" | awk '/loss/{print $6}' | tr -d '%')
|
|
168
169
|
if [ -n "$loss" ] && [ "$loss" -lt 1 ] 2>/dev/null; then
|
|
169
170
|
rtt=$(echo "$result" | awk -F'/' '/rtt/{print $5}')
|
|
@@ -333,7 +334,7 @@ EOF
|
|
|
333
334
|
# ─── COMMAND: list ────────────────────────────────────────────
|
|
334
335
|
cmd_list() {
|
|
335
336
|
load_active
|
|
336
|
-
title "TERMUX
|
|
337
|
+
title "TERMUX CONNECTING v${VERSION} — Devices"
|
|
337
338
|
local devices=()
|
|
338
339
|
while IFS= read -r d; do
|
|
339
340
|
devices+=("$d")
|
|
@@ -383,7 +384,7 @@ cmd_check() {
|
|
|
383
384
|
return
|
|
384
385
|
fi
|
|
385
386
|
|
|
386
|
-
title "TERMUX
|
|
387
|
+
title "TERMUX CONNECTING v${VERSION} — Check"
|
|
387
388
|
echo "Device: ${ACTIVE_DEVICE} (${SSH_USER}@${SSH_HOST}:${SSH_PORT})"
|
|
388
389
|
echo ""
|
|
389
390
|
|
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.55"
|
|
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,26 +9,38 @@ 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: timeout lintas platform ───
|
|
13
|
+
run_timeout() {
|
|
14
|
+
local sec="$1"; shift
|
|
15
|
+
if command -v timeout >/dev/null 2>&1; then
|
|
16
|
+
timeout "$sec" "$@"
|
|
17
|
+
elif command -v gtimeout >/dev/null 2>&1; then
|
|
18
|
+
gtimeout "$sec" "$@"
|
|
19
|
+
else
|
|
20
|
+
"$@"
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
# ─── Helper: dapatkan IP dengan berbagai metode ───
|
|
13
25
|
get_ip() {
|
|
14
26
|
local ip=""
|
|
15
27
|
if command -v ip >/dev/null; then
|
|
16
28
|
for iface in wlan0 wlan1 eth0 eth1 wlp2s0 wlp3s0 en0 en1; do
|
|
17
|
-
ip=$(
|
|
29
|
+
ip=$(run_timeout 2 ip -4 addr show $iface 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1)
|
|
18
30
|
[ -n "$ip" ] && break
|
|
19
31
|
done
|
|
20
32
|
if [ -z "$ip" ]; then
|
|
21
|
-
ip=$(
|
|
33
|
+
ip=$(run_timeout 2 ip route get 1.1.1.1 2>/dev/null | awk '{print $7}')
|
|
22
34
|
fi
|
|
23
35
|
if [ -z "$ip" ]; then
|
|
24
|
-
ip=$(
|
|
36
|
+
ip=$(run_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
37
|
fi
|
|
26
38
|
fi
|
|
27
39
|
if [ -z "$ip" ] && command -v ifconfig >/dev/null; then
|
|
28
|
-
ip=$(
|
|
40
|
+
ip=$(run_timeout 2 ifconfig 2>/dev/null | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
|
|
29
41
|
fi
|
|
30
42
|
if [ -z "$ip" ] && command -v getprop >/dev/null; then
|
|
31
|
-
local iface=$(getprop wifi.interface)
|
|
43
|
+
local iface=$(getprop wifi.interface 2>/dev/null)
|
|
32
44
|
[ -n "$iface" ] && ip=$(getprop dhcp.${iface}.ipaddress 2>/dev/null)
|
|
33
45
|
[ -z "$ip" ] && ip=$(getprop dhcp.wlan0.ipaddress 2>/dev/null)
|
|
34
46
|
[ -z "$ip" ] && ip=$(getprop dhcp.wlan1.ipaddress 2>/dev/null)
|
|
@@ -90,7 +102,7 @@ if $CHECK; then
|
|
|
90
102
|
echo ""
|
|
91
103
|
echo " 🌐 Network :"
|
|
92
104
|
for iface in wlan0 wlan1 eth0 eth1 wlp2s0 wlp3s0 en0 en1; do
|
|
93
|
-
addr=$(
|
|
105
|
+
addr=$(run_timeout 2 ip -4 addr show $iface 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1)
|
|
94
106
|
if [ -n "$addr" ]; then
|
|
95
107
|
echo " $iface : $addr"
|
|
96
108
|
fi
|
|
@@ -242,13 +254,13 @@ if [ -z "$ip" ]; then
|
|
|
242
254
|
echo " Hubungkan HP ke WiFi, lalu ulangi: termux-connecting -y"
|
|
243
255
|
exit 1
|
|
244
256
|
fi
|
|
245
|
-
gateway=$(
|
|
257
|
+
gateway=$(run_timeout 3 ip route 2>/dev/null | awk '/default via/{print $3}' | head -1)
|
|
246
258
|
if [ -z "$gateway" ] && command -v getprop >/dev/null; then
|
|
247
259
|
iface=$(getprop wifi.interface 2>/dev/null); [ -z "$iface" ] && iface="wlan0"
|
|
248
260
|
gateway=$(getprop dhcp.${iface}.gateway 2>/dev/null)
|
|
249
261
|
fi
|
|
250
262
|
if [ -n "$gateway" ]; then
|
|
251
|
-
result=$(
|
|
263
|
+
result=$(run_timeout 5 ping -c 2 -W 2 "$gateway" 2>&1)
|
|
252
264
|
loss=$(echo "$result" | awk '/loss/{print $6}' | tr -d '%')
|
|
253
265
|
if [ -n "$loss" ] && [ "$loss" -lt 1 ] 2>/dev/null; then
|
|
254
266
|
info "Jaringan stabil (0% loss) — IP: $ip"
|
|
@@ -393,7 +405,7 @@ title "6. Cek Stabilitas Jaringan"
|
|
|
393
405
|
STABLE=false
|
|
394
406
|
if [ -n "$IP" ]; then
|
|
395
407
|
echo " Ping gateway untuk verifikasi koneksi..."
|
|
396
|
-
|
|
408
|
+
gateway=$(run_timeout 3 ip route 2>/dev/null | awk '/default via/{print $3}' | head -1)
|
|
397
409
|
if [ -z "$gateway" ] && command -v getprop >/dev/null; then
|
|
398
410
|
iface=$(getprop wifi.interface 2>/dev/null)
|
|
399
411
|
[ -z "$iface" ] && iface="wlan0"
|
|
@@ -401,7 +413,7 @@ if [ -n "$IP" ]; then
|
|
|
401
413
|
fi
|
|
402
414
|
if [ -n "$gateway" ]; then
|
|
403
415
|
echo " Gateway: $gateway"
|
|
404
|
-
|
|
416
|
+
result=$(run_timeout 5 ping -c 2 -W 2 "$gateway" 2>&1)
|
|
405
417
|
loss=$(echo "$result" | awk '/loss/{print $6}' | tr -d '%')
|
|
406
418
|
if [ -n "$loss" ] && [ "$loss" -lt 1 ] 2>/dev/null; then
|
|
407
419
|
STABLE=true
|