From 94cb6009866f4ebc16d92087c0440adb98f18299 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 6 Oct 2014 19:30:06 +0200 Subject: Use eventlog in init and update API, populate database with default values on init --- inc/trigger.inc.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'inc/trigger.inc.php') diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index e6f7cd31..0b31c7b3 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -31,22 +31,25 @@ class Trigger * Try to automatically determine the primary IP address of the server. * This only works if the server has either one public IPv4 address (and potentially * one or more non-public addresses), or one private address. + * + * @return boolean true if current configured IP address is still valid, or if a new address could + * successfully be determined, false otherwise */ public static function autoUpdateServerIp() { $task = Taskmanager::submit('LocalAddressesList'); if ($task === false) - return; + return false; $task = Taskmanager::waitComplete($task, 10000); if (!isset($task['data']['addresses']) || empty($task['data']['addresses'])) - return; + return false; $serverIp = Property::getServerIp(); $publicCandidate = 'none'; $privateCandidate = 'none'; foreach ($task['data']['addresses'] as $addr) { if ($addr['ip'] === $serverIp) - return; + return true; if (substr($addr['ip'], 0, 4) === '127.') continue; if (Util::isPublicIpv4($addr['ip'])) { @@ -63,12 +66,13 @@ class Trigger } if ($publicCandidate !== 'none' && $publicCandidate !== 'many') { Property::setServerIp($publicCandidate); - return; + return true; } if ($privateCandidate !== 'none' && $privateCandidate !== 'many') { Property::setServerIp($privateCandidate); - return; + return true; } + return false; } /** -- cgit v1.2.3-55-g7522