Last active
May 7, 2024 17:05
-
-
Save HQarroum/179183a96c5991685d9cd7f0da882385 to your computer and use it in GitHub Desktop.
Using socat to forward traffic from a network interface to the loopback address on which ADB is listening.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Installing required packages for the Android SDK | |
# and the emulator. | |
sudo apt update -y && \ | |
DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends \ | |
socat \ | |
iproute2 | |
# The local ADB port. | |
ADB_PORT=5555 | |
# Resolving the IP address of the network interface. | |
LOCAL_IP=$(curl --silent http://169.254.169.254/latest/meta-data/local-ipv4) | |
# Running socat in the background to forward TCP traffic | |
# between the network interface and the loopback address. | |
socat tcp-listen:"$ADB_PORT",bind="$LOCAL_IP",tcp-nodelay,fork tcp:127.0.0.1:"$ADB_PORT" & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment