is_file($fileName)
) && (
is_readable($fileName)
- ) && (
- filesize($fileName) > 100
)
);
// CFG: REGISTRY-ITERATOR-CLASS
$cfg->setConfigEntry('registry_iterator_class', 'CoreFramework\Iterator\Registry\RegistryIterator');
+// CFG: QUIET-DNS-RESOLVER
+$cfg->setConfigEntry('quiet_dns_resolver', FALSE);
+
// Remove config from this name-space. Don't worry, no configuration is cleared.
unset($cfg);
$this->setServerAddress($serverIp);
} else {
// Run auto-detecting through console tools lib
- ConsoleTools::acquireSelfIPAddress();
+ ConsoleTools::acquireSelfIpAddress();
}
} // END - if
const HTTP_EOL = "\r\n";
const HTTP_USER_AGENT = 'ConsoleTools/1.0';
+ /**
+ * Default is that this class is noisy
+ */
+ private static $quietResolver = FALSE;
+
/**
* Protected constructor
*
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Cache configuration entry
+ self::$quietResolver = FrameworkConfiguration::getSelfInstance()->getConfigEntry('quiet_dns_resolver');
}
/**
* @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;
// 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.',
*
* @return $ipAddress Aquired IPv4 address
*/
- public static function acquireSelfIPAddress () {
+ public static function acquireSelfIpAddress () {
// Local IP by default
$ipAddress = '127.0.0.1';
namespace CoreFramework\Configuration;
// Inport framework stuff
+use CoreFramework\Console\Tools\ConsoleTools;
use CoreFramework\Loader\ClassLoader;
use CoreFramework\Generic\NullPointerException;
*/
private static $configInstance = NULL;
+ /**
+ * Own IP address
+ */
+ private static $ipAddress = FALSE;
+
/**
* Setup test case
*/
*/
ClassLoader::enableStrictNamingConventionCheck(FALSE);
+ // Quiet DNS resolver as this is not wanted here
+ self::$configInstance->setConfigEntry('quiet_dns_resolver', TRUE);
+
+ // Lookup own IP address
+ self::$ipAddress = ConsoleTools::acquireSelfIpAddress();
+
// Trace message
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
$serverAddress = self::$configInstance->detectServerAddress();
// Should be the same
- $this->assertEquals('127.0.0.1', $serverAddress);
+ $this->assertEquals(self::$ipAddress, $serverAddress);
}
/**
$serverAddress = self::$configInstance->detectServerAddress();
// Should be the same
- $this->assertEquals('127.0.0.1', $serverAddress);
+ $this->assertEquals(self::$ipAddress, $serverAddress);
}
/**
// Should be equal
$this->assertEquals('127.0.0.1', $serverAddress);
+
+ // Set old back
+ self::$configInstance->setServerAddress(self::$ipAddress);
}
}