Skip to content

Commit

Permalink
Improve external IP detection
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Jan 22, 2024
1 parent 966b3d8 commit d4785c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion build/COPY_ROOT/opt/ai-dock/bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ function init_set_cf_tunnel_wanted() {

function init_direct_address() {
export EXTERNAL_IP_ADDRESS="$(dig +short myip.opendns.com @resolver1.opendns.com)"

if [[ -z $EXTERNAL_IP_ADDRESS ]];then
export EXTERNAL_IP_ADDRESS=$(curl -s ifconfig.me)
fi
if [[ ! -v DIRECT_ADDRESS ]]; then
DIRECT_ADDRESS=""
fi
Expand All @@ -364,9 +366,11 @@ function init_direct_address() {
elif env | grep 'VAST' > /dev/null 2>&1; then
export DIRECT_ADDRESS="auto#vast-ai"
export CLOUD_PROVIDER="vast.ai"
export EXTERNAL_IP_ADDRESS=${PUBLIC_IPADDR}
elif env | grep 'RUNPOD' > /dev/null 2>&1; then
export DIRECT_ADDRESS="auto#runpod-io"
export CLOUD_PROVIDER="runpod.io"
export EXTERNAL_IP_ADDRESS=${RUNPOD_PUBLIC_IP}
# Detected provider does not support direct connections
elif env | grep 'PAPERSPACE' > /dev/null 2>&1; then
export DIRECT_ADDRESS=""
Expand Down

0 comments on commit d4785c3

Please sign in to comment.