本文整理汇总了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;
}