本文整理匯總了TypeScript中os.hostname函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript hostname函數的具體用法?TypeScript hostname怎麽用?TypeScript hostname使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了hostname函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: encrypt
function encrypt(username, password) {
//OS.hostname() is the key.
//AES encryption
encryptedUsername = CryptoJS.AES.encrypt(username, os.hostname());
encryptedPassword = CryptoJS.AES.encrypt(password, os.hostname());
writetoJSON(encryptedUsername, encryptedPassword);
}
示例2: function
var workerProcess = child_process.exec(`cd ${libPath} && npm test`, bufferOption, function (error, stdout, stderr) {
clearTimeout(timeoutId);
if (error) {
//console.log(error.stack);
//console.log('MPN Error code: ' + error.code);
//console.log('MPNSignal received: ' + error.signal);
console.log(`{"sucess":"false", "host":"${os.hostname()}", "duration":"${clock(start)}"}`);
process.exit(error.code);
}
//console.log('MPN stdout: ' + stdout);
//console.log('MPNstderr: ' + stderr);
console.log(`{"sucess":"true", "host":"${os.hostname()}", "duration":"${clock(start)}"}`);
process.exit();
});
示例3: getPassword
function getPassword() {
var decryptedPasswordBytes = CryptoJS.AES.decrypt(
encryptedPassword.toString(),
os.hostname()
);
return decryptedPasswordBytes.toString(CryptoJS.enc.Utf8);
}
示例4: machineId
return machineId().catch(() => {
// In case MachineId fails
const hash = crypto.createHash('sha256')
const network = os.networkInterfaces()
hash.update(os.arch() + os.hostname() + os.platform() + os.type() + network['mac'])
return hash.digest('hex')
})
示例5: extractFullyQualifiedDomainName
export async function extractFullyQualifiedDomainName(): Promise<string> {
if (_fullyQualifiedDomainNameInCache) {
return _fullyQualifiedDomainNameInCache;
}
if (false && process.platform === "win32") {
// http://serverfault.com/a/73643/251863
const env = process.env;
_fullyQualifiedDomainNameInCache = env.COMPUTERNAME
+ ((env.USERDNSDOMAIN && env.USERDNSDOMAIN!.length > 0) ? "." + env.USERDNSDOMAIN : "");
} else {
try {
_fullyQualifiedDomainNameInCache = await promisify(fqdn)();
if (/sethostname/.test(_fullyQualifiedDomainNameInCache as string)) {
throw new Error("Detecting fqdn on windows !!!");
}
} catch (err) {
// fall back to old method
_fullyQualifiedDomainNameInCache = os.hostname();
}
}
return _fullyQualifiedDomainNameInCache!;
}
示例6:
handler: () => ({
hostname: os.hostname(),
arch: os.arch(),
platfoirm: os.platform(),
cpus: os.cpus().length,
totalmem: humanize.filesize(os.totalmem()),
networkInterfaces: os.networkInterfaces()
})
示例7: constructor
constructor() {
this.name = NAME;
this.nickname = RandomName({ last: true });
this.hostname = os.hostname();
this.pid = process.pid;
this.boundLog = null;
this.boundError = null;
}
示例8: function
controller.hears(["uptime", "identify yourself", "who are you", "what is your name"], "direct_message,direct_mention,mention", function (bot, message) {
let hostname = os.hostname();
let uptime = formatUptime(process.uptime());
bot.reply(message, ":robot_face: I am a bot named <@" + bot.identity.name + ">. I have been running for " + uptime + " on " + hostname + ".");
});
示例9: getUsername
function getUsername() {
if (encryptedUsername != null) {
var decryptedUsernameBytes = CryptoJS.AES.decrypt(
encryptedUsername.toString(),
os.hostname()
);
return decryptedUsernameBytes.toString(CryptoJS.enc.Utf8);
}
}
示例10: parseRequest
export function parseRequest(
event: Event,
req: {
[key: string]: any;
},
options?: {
request?: boolean;
serverName?: boolean;
transaction?: boolean | TransactionTypes;
user?: boolean | string[];
version?: boolean;
},
): Event {
// tslint:disable-next-line:no-parameter-reassignment
options = {
request: true,
serverName: true,
transaction: true,
user: true,
version: true,
...options,
};
if (options.version) {
event.extra = {
...event.extra,
node: global.process.version,
};
}
if (options.request) {
event.request = {
...event.request,
...extractRequestData(req),
};
}
if (options.serverName) {
event.server_name = global.process.env.SENTRY_NAME || os.hostname();
}
if (options.user && req.user) {
event.user = {
...event.user,
...extractUserData(req, options.user),
};
}
if (options.transaction) {
const transaction = extractTransaction(req, options.transaction);
if (transaction) {
event.transaction = transaction;
}
}
return event;
}