• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript os.networkInterfaces函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中os.networkInterfaces函数的典型用法代码示例。如果您正苦于以下问题:TypeScript networkInterfaces函数的具体用法?TypeScript networkInterfaces怎么用?TypeScript networkInterfaces使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了networkInterfaces函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: value

	value(): number {
		if (this._value === undefined) {
			let vmOui = 0;
			let interfaceCount = 0;

			const interfaces = networkInterfaces();
			for (let name in interfaces) {
				if (Object.prototype.hasOwnProperty.call(interfaces, name)) {
					for (const { mac, internal } of interfaces[name]) {
						if (!internal) {
							interfaceCount += 1;
							if (this._isVirtualMachineMacAdress(mac.toUpperCase())) {
								vmOui += 1;
							}
						}
					}
				}
			}
			this._value = interfaceCount > 0
				? vmOui / interfaceCount
				: 0;
		}

		return this._value;
	}
开发者ID:Chan-PH,项目名称:vscode,代码行数:25,代码来源:id.ts


示例2: 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


示例3: networkInterfaces

export function networkInterfaces() {
	const os = require('os');
	const ifaces = os.networkInterfaces();
	const faces = [];

	Object.keys(ifaces).forEach(function (ifname) {
		let alias = 0;

		ifaces[ifname].forEach(function (iface) {
			if ('IPv4' !== iface.family || iface.internal !== false) {
				// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
				return;
			}

			if (alias >= 1) {
				faces.push({name: ifname + ':' + alias, address: iface.address});
				// this single interface has multiple ipv4 addresses
			} else {
				// this interface has only one ipv4 adress
				faces.push({name: ifname, address: iface.address});
			}
			++alias;
		});
	});

	return faces;
}
开发者ID:w3gh,项目名称:ghost.js,代码行数:27,代码来源:util.ts


示例4:

 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


示例5: getIpAddress

function getIpAddress(): string {
  const interfaces = networkInterfaces();
  let ips: string[] = Object.keys(interfaces)
    .reduce((results, name) => results.concat(interfaces[name]), [])
    .filter((iface) => iface.family === "IPv4" && !iface.internal)
    .map((iface) => iface.address);
  return ips[0] ? ips[0] : "unknown";
}
开发者ID:tcdl,项目名称:msb,代码行数:8,代码来源:serviceDetails.ts


示例6: bindingOutput

function bindingOutput(port: number) {
  let networkInterfaces = os.networkInterfaces();
  for (let key in networkInterfaces) {
    let items = networkInterfaces[key];
    let validItems = items.filter(item => item.family === 'IPv4');
    for (let validInterface of validItems) console.log(`Listening on ${validInterface.address}:${port}`);
  }
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:8,代码来源:serve.ts


示例7: function

export default function () {
  // TODO(architect): Delete this test. It is now in devkit/build-webpack.

  const firstLocalIp = _(os.networkInterfaces())
    .values()
    .flatten()
    .filter({ family: 'IPv4', internal: false })
    .map('address')
    .first();
  const publicHost = `${firstLocalIp}:4200`;
  const localAddress = `http://${publicHost}`;

  return Promise.resolve()
    // Disabling this test. Webpack Dev Server does not check the hots anymore when binding to
    // numeric IP addresses.
    // .then(() => ngServe('--host=0.0.0.0'))
    // .then(() => request(localAddress))
    // .then(body => {
    //   if (!body.match(/Invalid Host header/)) {
    //     throw new Error('Response does not match expected value.');
    //   }
    // })
    // .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; })
    .then(() => ngServe('--host=0.0.0.0', `--public-host=${publicHost}`))
    .then(() => request(localAddress))
    .then(body => {
      if (!body.match(/<app-root><\/app-root>/)) {
        throw new Error('Response does not match expected value.');
      }
    })
    .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; })
    .then(() => ngServe('--host=0.0.0.0', `--disable-host-check`))
    .then(() => request(localAddress))
    .then(body => {
      if (!body.match(/<app-root><\/app-root>/)) {
        throw new Error('Response does not match expected value.');
      }
    })
    .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; })
    .then(() => ngServe('--host=0.0.0.0', `--public-host=${localAddress}`))
    .then(() => request(localAddress))
    .then(body => {
      if (!body.match(/<app-root><\/app-root>/)) {
        throw new Error('Response does not match expected value.');
      }
    })
    .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; })
    .then(() => ngServe('--host=0.0.0.0', `--public-host=${firstLocalIp}`))
    .then(() => request(localAddress))
    .then(body => {
      if (!body.match(/<app-root><\/app-root>/)) {
        throw new Error('Response does not match expected value.');
      }
    })
    .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; });
}
开发者ID:samsif,项目名称:angular-cli,代码行数:56,代码来源:public-host.ts


示例8: getMac

function getMac() {
  const interfaces = os.networkInterfaces()
  return Object.keys(interfaces).reduce((acc, key) => {
    if (acc) {
      return acc
    }
    const i = interfaces[key]
    const mac = i.find(a => a.mac !== '00:00:00:00:00:00')
    return mac ? mac.mac : null
  }, null)
}
开发者ID:nunsie,项目名称:prisma,代码行数:11,代码来源:StatusChecker.ts


示例9: listInterfaces

function listInterfaces() {
  const netInterfaces = os.networkInterfaces();
  const keys = _.keys(netInterfaces);
  const res = [];
  for (const name of keys) {
    res.push({
      name: name,
      addresses: netInterfaces[name]
    });
  }
  return res;
}
开发者ID:Kalmac,项目名称:duniter,代码行数:12,代码来源:network.ts


示例10: resolve

 return new Promise<Location>((resolve, reject) => {
   let ifaces = os.networkInterfaces();
   for (let ifacePos in ifaces) {
     ifaces[ifacePos].forEach(iface => {
       if (iface.family === 'IPv4' && !iface.internal) {
         logger.debug('mac address:', iface.mac);
         location.macAddress = iface.mac;
         resolve(location);
       }
     });
   }
 });
开发者ID:alt-locator,项目名称:alt-node,代码行数:12,代码来源:location.ts



注:本文中的os.networkInterfaces函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript os.platform函数代码示例发布时间:2022-05-25
下一篇:
TypeScript os.loadavg函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap