function SystemNodeProvider::getIfconfig
Returns the network interface configuration for the system
@codeCoverageIgnore
1 call to SystemNodeProvider::getIfconfig()
- SystemNodeProvider::getNodeFromSystem in vendor/
ramsey/ uuid/ src/ Provider/ Node/ SystemNodeProvider.php - Returns the system node, if it can find it
File
-
vendor/
ramsey/ uuid/ src/ Provider/ Node/ SystemNodeProvider.php, line 99
Class
- SystemNodeProvider
- SystemNodeProvider retrieves the system node ID, if possible
Namespace
Ramsey\Uuid\Provider\NodeCode
protected function getIfconfig() : string {
$disabledFunctions = strtolower((string) ini_get('disable_functions'));
if (str_contains($disabledFunctions, 'passthru')) {
return '';
}
/**
* @psalm-suppress UnnecessaryVarAnnotation
* @var string $phpOs
*/
$phpOs = constant('PHP_OS');
ob_start();
switch (strtoupper(substr($phpOs, 0, 3))) {
case 'WIN':
passthru('ipconfig /all 2>&1');
break;
case 'DAR':
passthru('ifconfig 2>&1');
break;
case 'FRE':
passthru('netstat -i -f link 2>&1');
break;
case 'LIN':
default:
passthru('netstat -ie 2>&1');
break;
}
$ifconfig = (string) ob_get_clean();
if (preg_match_all(self::IFCONFIG_PATTERN, $ifconfig, $matches, PREG_PATTERN_ORDER)) {
foreach ($matches[1] as $iface) {
if ($iface !== '00:00:00:00:00:00' && $iface !== '00-00-00-00-00-00') {
return $iface;
}
}
}
return '';
}