X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=framework%2Fmain%2Fclasses%2Ftools%2Fconsole%2Fclass_ConsoleTools.php;h=feafde705c0702c1ee0375fd07b0189fc29b29cc;hb=b002c5909aa0f781505dde5414964b0f014cde01;hp=c1d252d51e8db3267a8bd3230928f00ab4721b59;hpb=197d364f62d39e6f731ff62001ac6cafccc0d9cc;p=core.git diff --git a/framework/main/classes/tools/console/class_ConsoleTools.php b/framework/main/classes/tools/console/class_ConsoleTools.php index c1d252d5..feafde70 100644 --- a/framework/main/classes/tools/console/class_ConsoleTools.php +++ b/framework/main/classes/tools/console/class_ConsoleTools.php @@ -1,13 +1,17 @@ getConfigEntry('quiet_dns_resolver'); } /** @@ -167,11 +179,14 @@ class ConsoleTools extends BaseFrameworkSystem { * @todo This should be connected to a caching class to cache DNS requests */ public static function resolveIpAddress ($hostname) { - // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s', - __CLASS__, - $hostname - )); + // Quiet? + if (self::$quietResolver !== TRUE) { + // Debug message + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s', + __CLASS__, + $hostname + )); + } // END - if // Default is false $ipAddress = false; @@ -197,11 +212,14 @@ class ConsoleTools extends BaseFrameworkSystem { // Okay, this works! $ipAddress = $ipResolved; - // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s', - __CLASS__, - $ipAddress - )); + // Quiet? + if (self::$quietResolver !== TRUE) { + // Debug message + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s', + __CLASS__, + $ipAddress + )); + } // END - if } else { // Problem while resolving IP address self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.', @@ -220,16 +238,19 @@ class ConsoleTools extends BaseFrameworkSystem { * * @return $ipAddress Aquired IPv4 address */ - public static function acquireSelfIPAddress () { + public static function acquireSelfIpAddress () { // Local IP by default $ipAddress = '127.0.0.1'; // Get a new instance $helperInstance = new ConsoleTools(); + // Get SplFileInfo instance + $infoInstance = new SplFileInfo($helperInstance->getConfigInstance()->getConfigEntry('hostname_file')); + try { // Get a file pointer - $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($helperInstance->getConfigInstance()->getConfigEntry('hostname_file'))); + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($infoInstance)); // Read the file $rawData = trim($fileInstance->readFromFile()); @@ -266,9 +287,6 @@ class ConsoleTools extends BaseFrameworkSystem { )); } - // Set it in configuration - FrameworkConfiguration::getSelfInstance()->setServerAddress($ipAddress); - // Return it return $ipAddress; }