當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript os.hostname函數代碼示例

本文整理匯總了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);
    
}
開發者ID:cchampernowne,項目名稱:project-seed,代碼行數:12,代碼來源:storeCredentials.ts

示例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();
});
開發者ID:ffarzat,項目名稱:JavaScriptHeuristicOptmizer,代碼行數:15,代碼來源:client.ts

示例3: getPassword

function getPassword() {
  var decryptedPasswordBytes = CryptoJS.AES.decrypt(
    encryptedPassword.toString(),
    os.hostname()
  );
  return decryptedPasswordBytes.toString(CryptoJS.enc.Utf8);
}
開發者ID:cchampernowne,項目名稱:project-seed,代碼行數:7,代碼來源:readCredentials.ts

示例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')
 })
開發者ID:alexsandrocruz,項目名稱:botpress,代碼行數:7,代碼來源:stats.ts

示例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!;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:26,代碼來源:hostname.ts

示例6:

 handler: () => ({
   hostname: os.hostname(),
   arch: os.arch(),
   platfoirm: os.platform(),
   cpus: os.cpus().length,
   totalmem: humanize.filesize(os.totalmem()),
   networkInterfaces: os.networkInterfaces()
 })
開發者ID:pdxmholmes,項目名稱:alpine-node-hello,代碼行數:8,代碼來源:index.ts

示例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;
 }
開發者ID:WordToken,項目名稱:voice-web,代碼行數:8,代碼來源:logger.ts

示例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 + ".");

});
開發者ID:philschonholzer,項目名稱:chefbot,代碼行數:8,代碼來源:bot.ts

示例9: getUsername

function getUsername() {
  if (encryptedUsername != null) {
    var decryptedUsernameBytes = CryptoJS.AES.decrypt(
      encryptedUsername.toString(),
      os.hostname()
    );
    return decryptedUsernameBytes.toString(CryptoJS.enc.Utf8);
  }
}
開發者ID:cchampernowne,項目名稱:project-seed,代碼行數:9,代碼來源:readCredentials.ts

示例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;
}
開發者ID:getsentry,項目名稱:raven-js,代碼行數:57,代碼來源:handlers.ts


注:本文中的os.hostname函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。