first commit

This commit is contained in:
monjack
2025-06-20 18:01:48 +08:00
commit 6daa6d65c1
24611 changed files with 2512443 additions and 0 deletions

22
app_vue/node_modules/address/LICENSE.txt generated vendored Normal file
View File

@ -0,0 +1,22 @@
This software is licensed under the MIT License.
Copyright (C) 2013 - 2014 fengmk2 <fengmk2@gmail.com>
Copyright (C) 2015 - present node-modules and other contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

93
app_vue/node_modules/address/README.md generated vendored Normal file
View File

@ -0,0 +1,93 @@
address
=======
[![NPM version][npm-image]][npm-url]
[![Node.js CI](https://github.com/node-modules/address/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/address/actions/workflows/nodejs.yml)
[![Test coverage][coveralls-image]][coveralls-url]
[![npm download][download-image]][download-url]
[npm-image]: https://img.shields.io/npm/v/address.svg?style=flat-square
[npm-url]: https://npmjs.org/package/address
[coveralls-image]: https://img.shields.io/coveralls/node-modules/address.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/node-modules/address?branch=master
[download-image]: https://img.shields.io/npm/dm/address.svg?style=flat-square
[download-url]: https://npmjs.org/package/address
Get current machine IP, MAC and DNS servers.
DNS servers receive from `/etc/resolv.conf`.
## Install
```bash
$ npm install address
```
## Usage
Get IP is sync and get MAC is async for now.
```js
const address = require('address');
// default interface 'eth' on linux, 'en' on osx.
address.ip(); // '192.168.0.2'
address.ipv6(); // 'fe80::7aca:39ff:feb0:e67d'
address.mac(function (err, addr) {
console.log(addr); // '78:ca:39:b0:e6:7d'
});
// local loopback
address.ip('lo'); // '127.0.0.1'
// vboxnet MAC
address.mac('vboxnet', function (err, addr) {
console.log(addr); // '0a:00:27:00:00:00'
});
```
### Get all addresses: IPv4, IPv6 and MAC
```js
address((err, addrs) => {
console.log(addrs.ip, addrs.ipv6, addrs.mac);
// '192.168.0.2', 'fe80::7aca:39ff:feb0:e67d', '78:ca:39:b0:e6:7d'
});
address('vboxnet', (err, addrs) => {
console.log(addrs.ip, addrs.ipv6, addrs.mac);
// '192.168.56.1', null, '0a:00:27:00:00:00'
});
```
### Get an interface info with family
```js
address.interface('IPv4', 'eth1');
// { address: '192.168.1.1', family: 'IPv4', mac: '78:ca:39:b0:e6:7d' }
```
### Get DNS servers
```js
address.dns((err, addrs) => {
console.log(addrs);
// ['10.13.2.1', '10.13.2.6']
});
```
## License
[MIT](LICENSE.txt)
<!-- GITCONTRIBUTOR_START -->
## Contributors
|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/1147375?v=4" width="100px;"/><br/><sub><b>alsotang</b></sub>](https://github.com/alsotang)<br/>|[<img src="https://avatars.githubusercontent.com/u/10237910?v=4" width="100px;"/><br/><sub><b>jkelleyrtp</b></sub>](https://github.com/jkelleyrtp)<br/>|[<img src="https://avatars.githubusercontent.com/u/1409643?v=4" width="100px;"/><br/><sub><b>mariodu</b></sub>](https://github.com/mariodu)<br/>|[<img src="https://avatars.githubusercontent.com/u/11351322?v=4" width="100px;"/><br/><sub><b>mathieutu</b></sub>](https://github.com/mathieutu)<br/>|[<img src="https://avatars.githubusercontent.com/u/2139038?v=4" width="100px;"/><br/><sub><b>zhangyuheng</b></sub>](https://github.com/zhangyuheng)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
[<img src="https://avatars.githubusercontent.com/u/1400114?v=4" width="100px;"/><br/><sub><b>coolme200</b></sub>](https://github.com/coolme200)<br/>|[<img src="https://avatars.githubusercontent.com/u/5856440?v=4" width="100px;"/><br/><sub><b>whxaxes</b></sub>](https://github.com/whxaxes)<br/>
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Tue Sep 13 2022 09:09:11 GMT+0800`.
<!-- GITCONTRIBUTOR_END -->

28
app_vue/node_modules/address/lib/address.d.ts generated vendored Normal file
View File

@ -0,0 +1,28 @@
export = address;
declare interface Address {
ip: string;
ipv6: string;
mac: string;
}
declare type AddressCallback = (err: Error, addr: Address) => void;
declare type MacCallback = (err: Error, addr: string) => void;
declare type DnsCallback = (err: Error, servers: string[]) => void;
declare function address(interfaceName: string, callback: AddressCallback): void;
declare function address(callback: AddressCallback): void;
declare namespace address {
const MAC_IP_RE: RegExp;
const MAC_RE: RegExp;
function dns(filepath: string, callback: DnsCallback): void;
function dns(callback: DnsCallback): void;
function ip(interfaceName?: string): any;
function ipv6(interfaceName?: string): any;
function mac(interfaceName: string, callback: MacCallback): void;
function mac(callback: MacCallback): void;
}

263
app_vue/node_modules/address/lib/address.js generated vendored Normal file
View File

@ -0,0 +1,263 @@
'use strict';
var os = require('os');
var fs = require('fs');
var child = require('child_process');
var DEFAULT_RESOLV_FILE = '/etc/resolv.conf';
function getInterfaceName() {
var val = 'eth';
var platform = os.platform();
if (platform === 'darwin') {
val = 'en';
} else if (platform === 'win32') {
val = null;
}
return val;
}
function getIfconfigCMD() {
if (os.platform() === 'win32') {
return 'ipconfig/all';
}
return '/sbin/ifconfig';
}
// typeof os.networkInterfaces family is a number (v18.0.0)
// types: 'IPv4' | 'IPv6' => 4 | 6
// @see https://github.com/nodejs/node/issues/42861
function matchName(actualFamily, expectedFamily) {
if (expectedFamily === 'IPv4') {
return actualFamily === 'IPv4' || actualFamily === 4;
}
if (expectedFamily === 'IPv6') {
return actualFamily === 'IPv6' || actualFamily === 6;
}
return actualFamily === expectedFamily;
}
/**
* Get all addresses.
*
* @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os.
* @param {Function(err, addr)} callback
* - {Object} addr {
* - {String} ip
* - {String} ipv6
* - {String} mac
* }
*/
function address(interfaceName, callback) {
if (typeof interfaceName === 'function') {
callback = interfaceName;
interfaceName = null;
}
var addr = {
ip: address.ip(interfaceName),
ipv6: address.ipv6(interfaceName),
mac: null
};
address.mac(interfaceName, function (err, mac) {
if (mac) {
addr.mac = mac;
}
callback(err, addr);
});
}
address.interface = function (family, name) {
var interfaces = os.networkInterfaces();
var noName = !name;
name = name || getInterfaceName();
family = family || 'IPv4';
for (var i = -1; i < 8; i++) {
var interfaceName = name + (i >= 0 ? i : ''); // support 'lo' and 'lo0'
var items = interfaces[interfaceName];
if (items) {
for (var j = 0; j < items.length; j++) {
var item = items[j];
if (matchName(item.family, family)) {
return item;
}
}
}
}
if (noName) {
// filter all loopback or local addresses
for (var k in interfaces) {
var items = interfaces[k];
for (var i = 0; i < items.length; i++) {
var item = items[i];
// all 127 addresses are local and should be ignored
if (matchName(item.family, family) && !item.address.startsWith('127.')) {
return item;
}
}
}
}
return;
};
/**
* Get current machine IPv4
*
* @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os.
* @return {String} IP address
*/
address.ip = function (interfaceName) {
var item = address.interface('IPv4', interfaceName);
return item && item.address;
};
/**
* Get current machine IPv6
*
* @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os.
* @return {String} IP address
*/
address.ipv6 = function (interfaceName) {
var item = address.interface('IPv6', interfaceName);
return item && item.address;
};
// osx start line 'en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500'
// linux start line 'eth0 Link encap:Ethernet HWaddr 00:16:3E:00:0A:29 '
var MAC_OSX_START_LINE = /^(\w+)\:\s+flags=/;
var MAC_LINUX_START_LINE = /^(\w+)\s{2,}link encap:\w+/i;
// ether 78:ca:39:b0:e6:7d
// HWaddr 00:16:3E:00:0A:29
var MAC_RE = address.MAC_RE = /(?:ether|HWaddr)\s+((?:[a-z0-9]{2}\:){5}[a-z0-9]{2})/i;
// osx: inet 192.168.2.104 netmask 0xffffff00 broadcast 192.168.2.255
// linux: inet addr:10.125.5.202 Bcast:10.125.15.255 Mask:255.255.240.0
var MAC_IP_RE = address.MAC_IP_RE = /inet\s(?:addr\:)?(\d+\.\d+\.\d+\.\d+)/;
function getMAC(content, interfaceName, matchIP) {
var lines = content.split('\n');
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trimRight();
var m = MAC_OSX_START_LINE.exec(line) || MAC_LINUX_START_LINE.exec(line);
if (!m) {
continue;
}
// check interface name
var name = m[1];
if (name.indexOf(interfaceName) !== 0) {
continue;
}
var ip = null;
var mac = null;
var match = MAC_RE.exec(line);
if (match) {
mac = match[1];
}
i++;
while (true) {
line = lines[i];
if (!line || MAC_OSX_START_LINE.exec(line) || MAC_LINUX_START_LINE.exec(line)) {
i--;
break; // hit next interface, handle next interface
}
if (!mac) {
match = MAC_RE.exec(line);
if (match) {
mac = match[1];
}
}
if (!ip) {
match = MAC_IP_RE.exec(line);
if (match) {
ip = match[1];
}
}
i++;
}
if (ip === matchIP) {
return mac;
}
}
}
/**
* Get current machine MAC address
*
* @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os.
* @param {Function(err, address)} callback
*/
address.mac = function (interfaceName, callback) {
if (typeof interfaceName === 'function') {
callback = interfaceName;
interfaceName = null;
}
interfaceName = interfaceName || getInterfaceName();
var item = address.interface('IPv4', interfaceName);
if (!item) {
return callback();
}
// https://github.com/nodejs/node/issues/13581
// bug in node 7.x and <= 8.4.0
if (!process.env.CI && (item.mac === 'ff:00:00:00:00:00' || item.mac === '00:00:00:00:00:00')) {
// wrong address, ignore it
item.mac = '';
}
if (item.mac) {
return callback(null, item.mac);
}
child.exec(getIfconfigCMD(), {timeout: 5000}, function (err, stdout, stderr) {
if (err || !stdout) {
return callback(err);
}
var mac = getMAC(stdout || '', interfaceName, item.address);
callback(null, mac);
});
};
// nameserver 172.24.102.254
var DNS_SERVER_RE = /^nameserver\s+(\d+\.\d+\.\d+\.\d+)$/i;
/**
* Get DNS servers.
*
* @param {String} [filepath] resolv config file path. default is '/etc/resolv.conf'.
* @param {Function(err, servers)} callback
*/
address.dns = function (filepath, callback) {
if (typeof filepath === 'function') {
callback = filepath;
filepath = null;
}
filepath = filepath || DEFAULT_RESOLV_FILE;
fs.readFile(filepath, 'utf8', function (err, content) {
if (err) {
return callback(err);
}
var servers = [];
content = content || '';
var lines = content.split('\n');
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
var m = DNS_SERVER_RE.exec(line);
if (m) {
servers.push(m[1]);
}
}
callback(null, servers);
});
};
module.exports = address;

42
app_vue/node_modules/address/package.json generated vendored Normal file
View File

@ -0,0 +1,42 @@
{
"name": "address",
"version": "1.2.2",
"description": "Get current machine IP, MAC and DNS servers.",
"main": "lib/address.js",
"types": "lib/address.d.ts",
"files": [
"lib"
],
"scripts": {
"lint": "eslint test",
"test": "egg-bin test",
"ci": "egg-bin cov",
"contributors": "git-contributor"
},
"dependencies": {},
"devDependencies": {
"@types/node": "14",
"egg-bin": "^5.6.1",
"eslint": "^8.30.0",
"eslint-config-egg": "^12.1.0",
"git-contributor": "^1.1.0",
"mm": "*",
"runscript": "^1.4.0",
"typescript": "4"
},
"repository": {
"type": "git",
"url": "git://github.com/node-modules/address.git"
},
"keywords": [
"address",
"ip",
"ipv4",
"mac"
],
"engines": {
"node": ">= 10.0.0"
},
"author": "fengmk2 <fengmk2@gmail.com>",
"license": "MIT"
}