Skip to content

Commit c65b3ad

Browse files
hilkeheremansthotegowda
authored andcommitted
Ignore all loopback addresses for ip detection
Summary: There is a bug with IP detection on Macs that have (1) multiple ethernet interfaces, (2) are using the second or third interface as their primary connection and (3) have extra loopback IPs configured (for example when running OpenVPN, running some Docker configurations or other more exotic applications). In those cases, automatic IP detection will falsely detect the IP as something like `127.94.0.1`, which will make it impossible to run debug builds from a physical device. The underlying network configurations looks something similar to this (irrelevant parts omitted): ``` lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP> inet 127.0.0.1 netmask 0xff000000 inet 127.94.0.1 netmask 0xff000000 nd6 options=201<PERFORMNUD,DAD> en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV> ether xx:xx:xx:xx:xx:xx nd6 options=201<PERFORMNUD,DAD> media: autoselect Closes facebook#13415 Differential Revision: D4859654 Pulled By: javache fbshipit-source-id: 3c5d06201c48a2dfe1c274ff433423e5d7f2cded
1 parent 491c08b commit c65b3ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packager/react-native-xcode.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ if [[ "$CONFIGURATION" = "Debug" && ! "$PLATFORM_NAME" == *simulator ]]; then
7878
PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH
7979
IP=$(ipconfig getifaddr en0)
8080
if [ -z "$IP" ]; then
81-
IP=$(ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2 | awk 'NR==1{print $1}')
81+
IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}')
8282
fi
8383

8484
if [ -z ${DISABLE_XIP+x} ]; then

0 commit comments

Comments
 (0)