Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/homebridge-camera-ui/node_modules/ping/lib/builder/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
var __ = require('underscore');
var util = require('util');
// Our library
var linuxBuilder = require('./linux');
var macBuilder = require('./mac');
var winBuilder = require('./win');
/**
* A factory creates argument builders for different platform
* @constructor
*/
function factory() {}
/**
* Check out linux platform
*/
factory.isLinux = function (p) {
var platforms = [
'aix',
'android',
'linux',
];
return platforms.indexOf(p) >= 0;
};
/**
* Check out macos platform
*/
factory.isMacOS = function (p) {
var platforms = [
'darwin',
'freebsd',
];
return platforms.indexOf(p) >= 0;
};
/**
* Check out window platform
*/
factory.isWindow = function (p) {
return p && p.match(/^win/) !== null;
};
/**
* Check whether given platform is supported
* @param {string} p - Name of the platform
* @return {bool} - True or False
*/
factory.isPlatformSupport = function (p) {
return __.some([
this.isWindow(p),
this.isLinux(p),
this.isMacOS(p),
]);
};
/**
* Return a path to the ping executable in the system
* @param {string} platform - Name of the platform
* @param {bool} v6 - Ping via ipv6 or not
* @return {string} - Executable path for system command ping
* @throw if given platform is not supported
*/
factory.getExecutablePath = function (platform, v6) {
if (!this.isPlatformSupport(platform)) {
throw new Error(util.format('Platform |%s| is not support', platform));
}
var ret = null;
if (platform === 'aix') {
ret = '/usr/sbin/ping';
} else if (factory.isLinux(platform)) {
ret = v6 ? 'ping6' : 'ping';
} else if (factory.isWindow(platform)) {
ret = process.env.SystemRoot + '/system32/ping.exe';
} else if (factory.isMacOS(platform)) {
ret = v6 ? '/sbin/ping6' : '/sbin/ping';
}
return ret;
};
/**
* Create a builder
* @param {string} platform - Name of the platform
* @return {object} - Argument builder
* @throw if given platform is not supported
*/
factory.createBuilder = function (platform) {
if (!this.isPlatformSupport(platform)) {
throw new Error(util.format('Platform |%s| is not support', platform));
}
var ret = null;
if (factory.isLinux(platform)) {
ret = linuxBuilder;
} else if (factory.isWindow(platform)) {
ret = winBuilder;
} else if (factory.isMacOS(platform)) {
ret = macBuilder;
}
return ret;
};
module.exports = factory;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0048 ]-- |