termux-connecting 1.1.20 → 1.1.21
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 +24 -11
- package/package.json +1 -1
package/bin/termux-connecting
CHANGED
|
@@ -144,21 +144,26 @@ USERNAME=$(whoami)
|
|
|
144
144
|
|
|
145
145
|
IP=""
|
|
146
146
|
if command -v ip >/dev/null; then
|
|
147
|
-
IP=$(ip -4 addr show | awk '/inet /{print $2}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -1)
|
|
147
|
+
IP=$(ip -4 addr show 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -1)
|
|
148
148
|
fi
|
|
149
149
|
if [ -z "$IP" ] && command -v ifconfig >/dev/null; then
|
|
150
|
-
IP=$(ifconfig | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
|
|
150
|
+
IP=$(ifconfig 2>/dev/null | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
|
|
151
151
|
fi
|
|
152
152
|
if [ -z "$IP" ] && command -v hostname >/dev/null; then
|
|
153
|
-
IP=$(hostname -I | awk '{print $1}')
|
|
153
|
+
IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
|
154
154
|
fi
|
|
155
155
|
if [ -z "$IP" ] && [ -d /data/data/com.termux ]; then
|
|
156
|
-
IP=$(ip route get 1.1.1.1 | awk '{print $7}' | head -1)
|
|
156
|
+
IP=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $7}' | head -1)
|
|
157
157
|
fi
|
|
158
158
|
if [ -z "$IP" ]; then
|
|
159
159
|
IP=""
|
|
160
160
|
fi
|
|
161
161
|
|
|
162
|
+
WIFI_SSID=""
|
|
163
|
+
if command -v termux-wifi-connectioninfo >/dev/null; then
|
|
164
|
+
WIFI_SSID=$(termux-wifi-connectioninfo 2>/dev/null | grep -o '"ssid":"[^"]*"' | cut -d'"' -f4)
|
|
165
|
+
fi
|
|
166
|
+
|
|
162
167
|
is_cgnat() {
|
|
163
168
|
[[ "$1" =~ ^10\. ]] || [[ "$1" =~ ^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\. ]]
|
|
164
169
|
}
|
|
@@ -170,6 +175,9 @@ is_wifi() {
|
|
|
170
175
|
echo " Username : $USERNAME"
|
|
171
176
|
echo " IP : ${IP:-tidak terdeteksi}"
|
|
172
177
|
echo " Port : 8022"
|
|
178
|
+
if [ -n "$WIFI_SSID" ]; then
|
|
179
|
+
echo " WiFi : $WIFI_SSID"
|
|
180
|
+
fi
|
|
173
181
|
echo ""
|
|
174
182
|
|
|
175
183
|
if [ -z "$IP" ]; then
|
|
@@ -180,7 +188,7 @@ if [ -z "$IP" ]; then
|
|
|
180
188
|
echo " 1. Buka Pengaturan → WiFi, hubungkan ke jaringan rumah/kantor"
|
|
181
189
|
echo " 2. Setelah terhubung, jalankan ulang: termux-connecting -y"
|
|
182
190
|
elif is_cgnat "$IP"; then
|
|
183
|
-
warn "IP ${IP} terdeteksi sebagai jaringan SELULER/VPN"
|
|
191
|
+
warn "IP ${IP} terdeteksi sebagai jaringan SELULER/VPN${WIFI_SSID:+ (WiFi terdeteksi: $WIFI_SSID)}"
|
|
184
192
|
echo " PC dan HP harus dalam jaringan WiFi yang SAMA."
|
|
185
193
|
echo ""
|
|
186
194
|
echo " Langkah:"
|
|
@@ -197,14 +205,19 @@ elif is_wifi "$IP"; then
|
|
|
197
205
|
echo " Lalu isi data di atas saat diminta."
|
|
198
206
|
echo " Setelah setup, cukup: ssh ${HOST_ALIAS:-termux-a8star}"
|
|
199
207
|
echo ""
|
|
200
|
-
|
|
208
|
+
if [ -n "$WIFI_SSID" ]; then
|
|
209
|
+
echo " PC harus terhubung ke WiFi: ${WIFI_SSID}"
|
|
210
|
+
else
|
|
211
|
+
warn "Pastikan HP dan PC terhubung ke jaringan WiFi YANG SAMA"
|
|
212
|
+
fi
|
|
201
213
|
echo ""
|
|
202
214
|
echo " Data koneksi — simpan untuk setup PC:"
|
|
203
|
-
echo "
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
215
|
+
echo " ┌──────────────────────────────────┐"
|
|
216
|
+
printf " │ %-32s │\n" "Username : $USERNAME"
|
|
217
|
+
printf " │ %-32s │\n" "IP : $IP"
|
|
218
|
+
printf " │ %-32s │\n" "Port : 8022"
|
|
219
|
+
[ -n "$WIFI_SSID" ] && printf " │ %-32s │\n" "WiFi : $WIFI_SSID"
|
|
220
|
+
echo " └──────────────────────────────────┘"
|
|
208
221
|
else
|
|
209
222
|
warn "IP ${IP} tidak dikenal — mungkin bukan jaringan lokal"
|
|
210
223
|
echo " Pastikan HP terhubung ke WiFi, bukan data seluler."
|