diff options
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 487efed..7c46eac 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -555,4 +555,23 @@ function mac_format($clientmac) { } } +function resolve_retry($hostname, $retries = 5) { + + if (is_ipaddr($hostname)) + return $hostname; + + for ($i = 0; $i < $retries; $i++) { + $ip = gethostbyname($hostname); + + if ($ip && $ip != $hostname) { + /* success */ + return $ip; + } + + sleep(1); + } + + return false; +} + ?>
\ No newline at end of file |