1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-11 16:57:23 +01:00

dont ask the user for the machine's IP address if we can be sure our guess is right (trust icanhazip to give us the right answer)

This commit is contained in:
Joshua Tauberer
2014-07-29 20:04:50 -04:00
parent 0be92d776e
commit cd59025979
2 changed files with 66 additions and 40 deletions

View File

@@ -70,20 +70,6 @@ function get_default_hostname {
printf '%s\n' "$1" # return this value
}
function get_default_publicip {
# Get the machine's public IP address. The machine might have
# an IP on a private network, but the IP address that we put
# into DNS must be one on the public Internet. Try a public
# API, but if that fails (maybe we don't have Internet access
# right now) then use the IP address that this machine knows
# itself as.
get_publicip_from_web_service 4 || get_default_privateip 4
}
function get_default_publicipv6 {
get_publicip_from_web_service 6 || get_default_privateip 6
}
function get_publicip_from_web_service {
# This seems to be the most reliable way to determine the
# machine's public IP address: asking a very nice web API