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/portfinder/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
node-portfinder
Copyright (c) 2012 Charlie Robbins
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.

75
app_vue/node_modules/portfinder/README.md generated vendored Normal file
View File

@ -0,0 +1,75 @@
# node-portfinder
[![CI](https://github.com/http-party/node-portfinder/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/http-party/node-portfinder/actions/workflows/ci.yml)
## Installation
You can install `portfinder` using a package manager like npm, yarn, or bun:
``` bash
npm install portfinder
```
## Usage
The `portfinder` module has a simple interface:
``` js
const portfinder = require('portfinder');
portfinder.getPort(function (err, port) {
//
// `port` is guaranteed to be a free port
// in this scope.
//
});
```
Or using promises:
``` js
const portfinder = require('portfinder');
portfinder.getPortPromise()
.then((port) => {
//
// `port` is guaranteed to be a free port
// in this scope.
//
})
.catch((err) => {
//
// Could not get a free port, `err` contains the reason.
//
});
```
### Ports search scope
By default `portfinder` will start searching from `8000` and scan until maximum port number (`65535`) is reached.
You can change this globally by setting:
```js
portfinder.setBasePort(3000); // default: 8000
portfinder.setHighestPort(3333); // default: 65535
```
or by passing optional options object on each invocation:
```js
portfinder.getPort({
port: 3000, // minimum port
stopPort: 3333 // maximum port
}, callback);
```
## Run Tests
``` bash
npm test
```
#### Author: [Charlie Robbins][0]
#### Author/Maintainer: [Erik Trom][1]
#### License: MIT/X11
[0]: http://nodejitsu.com
[1]: https://github.com/eriktrom

103
app_vue/node_modules/portfinder/lib/portfinder.d.ts generated vendored Normal file
View File

@ -0,0 +1,103 @@
/**
* portfinder.js typescript definitions.
*
* (C) 2011, Charlie Robbins
*/
type PortfinderCallback = (err: Error, port: number) => void;
interface PortFinderOptions {
/**
* Host to find available port on.
*/
host?: string;
/**
* search start port (equals to port when not provided)
* This exists because getPort and getPortPromise mutates port state in
* recursive calls and doesn't have a way to retrieve begininng port while
* searching.
*/
startPort?: number;
/**
* Minimum port (takes precedence over `basePort`).
*/
port?: number;
/**
* Maximum port
*/
stopPort?: number;
}
type SocketfinderCallback = (err: Error, socket: string) => void;
interface SocketFinderOptions {
/**
* Mode to use when creating folder for socket if it doesn't exist
*/
mod?: number;
/**
* Path to the socket file to create
* (defaults to `${exports.basePath}.sock` if not provided)
*/
path?: string;
}
/**
* The lowest port to begin any port search from.
*/
export let basePort: number;
/**
* Set the lowest port to begin any port search from.
*/
export function setBasePort(port: number): void;
/**
* The highest port to end any port search from.
*/
export let highestPort: number;
/**
* Set the higheset port to end any port search from.
*/
export function setHighestPort(port: number): void;
/**
* Default path to begin any socket search from.
*/
export let basePath: string;
/**
* Set the base path to begin any socket search from.
*/
export function setBasePath(path: string): void;
/**
* Responds with a unbound port on the current machine.
*/
export function getPort(options: PortFinderOptions): Promise<number>;
export function getPort(callback: PortfinderCallback): void;
export function getPort(options: PortFinderOptions, callback: PortfinderCallback): void;
/**
* Responds a promise of an unbound port on the current machine.
*/
export function getPortPromise(options?: PortFinderOptions): Promise<number>;
/**
* Responds with an array of unbound ports on the current machine.
*/
export function getPorts(count: number, options: PortFinderOptions): Promise<Array<number>>;
export function getPorts(count: number, callback: (err: Error, ports: Array<number>) => void): void;
export function getPorts(count: number, options: PortFinderOptions, callback: (err: Error, ports: Array<number>) => void): void;
/**
* Responds a promise that resolves to an array of unbound ports on the current machine.
*/
export function getPortsPromise(count: number, options?: PortFinderOptions): Promise<Array<number>>;
export function getSocket(options: SocketFinderOptions): Promise<string>;
export function getSocket(callback: SocketfinderCallback): void;
export function getSocket(options: SocketFinderOptions, callback: SocketfinderCallback): void;
export function getSocketPromise(options?: SocketFinderOptions): Promise<string>;

554
app_vue/node_modules/portfinder/lib/portfinder.js generated vendored Normal file
View File

@ -0,0 +1,554 @@
/*
* portfinder.js: A simple tool to find an open port on the current machine.
*
* (C) 2011, Charlie Robbins
*
*/
"use strict";
const fs = require('fs'),
os = require('os'),
net = require('net'),
path = require('path'),
_async = require('async'),
debug = require('debug');
const debugTestPort = debug('portfinder:testPort'),
debugGetPort = debug('portfinder:getPort'),
debugDefaultHosts = debug('portfinder:defaultHosts');
const internals = {};
internals.testPort = function(options, callback) {
if (!callback) {
callback = options;
options = {};
}
options.server = options.server || net.createServer(function () {
//
// Create an empty listener for the port testing server.
//
});
debugTestPort("entered testPort(): trying", options.host, "port", options.port);
function onListen () {
debugTestPort("done w/ testPort(): OK", options.host, "port", options.port);
options.server.removeListener('error', onError);
options.server.close(function () {
debugTestPort("done w/ testPort(): Server closed", options.host, "port", options.port);
callback(null, options.port);
});
}
function onError (err) {
debugTestPort("done w/ testPort(): failed", options.host, "w/ port", options.port, "with error", err.code);
options.server.removeListener('listening', onListen);
if (!(err.code == 'EADDRINUSE' || err.code == 'EACCES')) {
return callback(err);
}
const nextPort = exports.nextPort(options.port);
if (nextPort > exports.highestPort) {
return callback(new Error('No open ports available'));
}
internals.testPort({
port: nextPort,
host: options.host,
server: options.server
}, callback);
}
options.server.once('error', onError);
options.server.once('listening', onListen);
if (options.host) {
options.server.listen(options.port, options.host);
} else {
/*
Judgement of service without host
example:
express().listen(options.port)
*/
options.server.listen(options.port);
}
};
//
// ### @basePort {Number}
// The lowest port to begin any port search from
//
exports.basePort = 8000;
//
// ### function setBasePort (port)
// #### @port {Number} The new base port
//
exports.setBasePort = function (port) {
exports.basePort = port;
}
//
// ### @highestPort {Number}
// Largest port number is an unsigned short 2**16 -1=65335
//
exports.highestPort = 65535;
//
// ### function setHighestPort (port)
// #### @port {Number} The new highest port
//
exports.setHighestPort = function (port) {
exports.highestPort = port;
}
//
// ### @basePath {string}
// Default path to begin any socket search from
//
exports.basePath = '/tmp/portfinder'
//
// ### function setBasePath (path)
// #### @path {String} The new base path
//
exports.setBasePath = function (path) {
exports.basePath = path;
};
internals.getPort = function (options, callback) {
options.port = Number(options.port) || Number(options.startPort) || Number(exports.basePort);
options.host = options.host || null;
options.stopPort = Number(options.stopPort) || Number(exports.highestPort);
if (!options.startPort) {
options.startPort = options.port;
if (options.startPort < 0) {
return callback(Error(`Provided options.port(${options.port}) is less than 0, which are cannot be bound.`));
}
if (options.stopPort < options.startPort) {
return callback(Error(`Provided options.stopPort(${options.stopPort}) is less than options.port(${options.startPort})`));
}
}
if (options.host && exports._defaultHosts.indexOf(options.host) === -1) {
exports._defaultHosts.push(options.host)
}
const openPorts = [];
let currentHost;
return _async.eachSeries(exports._defaultHosts, function(host, next) {
debugGetPort("in eachSeries() iteration callback: host is", host);
return internals.testPort({ host: host, port: options.port }, function(err, port) {
if (err) {
debugGetPort("in eachSeries() iteration callback testPort() callback", "with an err:", err.code);
currentHost = host;
return next(err);
} else {
debugGetPort("in eachSeries() iteration callback testPort() callback",
"with a success for port", port);
openPorts.push(port);
return next();
}
});
}, function(err) {
if (err) {
debugGetPort("in eachSeries() result callback: err is", err);
// If we get EADDRNOTAVAIL it means the host is not bindable, so remove it
// from exports._defaultHosts and start over. For ubuntu, we use EINVAL for the same
if (err.code === 'EADDRNOTAVAIL' || err.code === 'EINVAL') {
if (options.host === currentHost) {
// if bad address matches host given by user, tell them
//
// NOTE: We may need to one day handle `my-non-existent-host.local` if users
// report frustration with passing in hostnames that DONT map to bindable
// hosts, without showing them a good error.
const msg = 'Provided host ' + options.host + ' could NOT be bound. Please provide a different host address or hostname';
return callback(Error(msg));
} else {
const idx = exports._defaultHosts.indexOf(currentHost);
exports._defaultHosts.splice(idx, 1);
return internals.getPort(options, callback);
}
} else {
// error is not accounted for, file ticket, handle special case
return callback(err);
}
}
// sort so we can compare first host to last host
openPorts.sort(function(a, b) {
return a - b;
});
debugGetPort("in eachSeries() result callback: openPorts is", openPorts);
if (openPorts[0] === openPorts[openPorts.length-1]) {
// if first === last, we found an open port
if(openPorts[0] <= options.stopPort) {
return callback(null, openPorts[0]);
}
else {
const msg = 'No open ports found in between '+ options.startPort + ' and ' + options.stopPort;
return callback(Error(msg));
}
} else {
// otherwise, try again, using sorted port, aka, highest open for >= 1 host
return internals.getPort({ port: openPorts.pop(), host: options.host, startPort: options.startPort, stopPort: options.stopPort }, callback);
}
});
};
// ### function getPort (options, callback)
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
// Responds with a unbound port on the current machine.
//
exports.getPort = function (options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
if (!callback) {
return new Promise(function (resolve, reject) {
internals.getPort(options, function (err, port) {
if (err) {
return reject(err);
}
resolve(port);
});
});
} else {
internals.getPort(options, callback);
}
};
//
// ### function getPortPromise (options)
// #### @options {Object} Settings to use when finding the necessary port
// Responds a promise to an unbound port on the current machine.
//
exports.getPortPromise = exports.getPort;
internals.getPorts = function (count, options, callback) {
let lastPort = null;
_async.timesSeries(count, function(index, asyncCallback) {
if (lastPort) {
options.port = exports.nextPort(lastPort);
}
internals.getPort(options, function (err, port) {
if (err) {
asyncCallback(err);
} else {
lastPort = port;
asyncCallback(null, port);
}
});
}, callback);
};
//
// ### function getPorts (count, options, callback)
// #### @count {Number} The number of ports to find
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
// Responds with an array of unbound ports on the current machine.
//
exports.getPorts = function (count, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
if (!callback) {
return new Promise(function(resolve, reject) {
internals.getPorts(count, options, function(err, ports) {
if (err) {
return reject(err);
}
resolve(ports);
});
});
} else {
internals.getPorts(count, options, callback);
}
};
//
// ### function getPortPromise (options)
// #### @count {Number} The number of ports to find
// #### @options {Object} Settings to use when finding the necessary port
// Responds with a promise that resolves to an array of unbound ports on the current machine.
//
exports.getPortsPromise = exports.getPorts;
internals.getSocket = function (options, callback) {
options.mod = options.mod || parseInt(755, 8);
options.path = options.path || exports.basePath + '.sock';
//
// Tests the specified socket
//
function testSocket () {
fs.stat(options.path, function (err) {
//
// If file we're checking doesn't exist (thus, stating it emits ENOENT),
// we should be OK with listening on this socket.
//
if (err) {
if (err.code == 'ENOENT') {
callback(null, options.path);
}
else {
callback(err);
}
}
else {
//
// This file exists, so it isn't possible to listen on it. Lets try
// next socket.
//
options.path = exports.nextSocket(options.path);
internals.getSocket(options, callback);
}
});
}
//
// Create the target `dir` then test connection
// against the socket.
//
function createAndTestSocket (dir) {
fs.mkdir(dir, { mode: options.mod, recursive: true }, function (err) {
if (err) {
return callback(err);
}
options.exists = true;
testSocket();
});
}
//
// Check if the parent directory of the target
// socket path exists. If it does, test connection
// against the socket. Otherwise, create the directory
// then test connection.
//
function checkAndTestSocket () {
const dir = path.dirname(options.path);
fs.stat(dir, function (err, stats) {
if (err || !stats.isDirectory()) {
return createAndTestSocket(dir);
}
options.exists = true;
testSocket();
});
}
//
// If it has been explicitly stated that the
// target `options.path` already exists, then
// simply test the socket.
//
return options.exists
? testSocket()
: checkAndTestSocket();
};
//
// ### function getSocket (options, callback)
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
// Responds with a unbound socket using the specified directory and base
// name on the current machine.
//
exports.getSocket = function (options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
if (!callback) {
return new Promise(function (resolve, reject) {
internals.getSocket(options, function (err, socketPath) {
if (err) {
return reject(err);
}
resolve(socketPath);
});
});
} else {
internals.getSocket(options, callback);
}
}
exports.getSocketPromise = exports.getSocket;
//
// ### function nextPort (port)
// #### @port {Number} Port to increment from.
// Gets the next port in sequence from the
// specified `port`.
//
exports.nextPort = function (port) {
return port + 1;
};
//
// ### function nextSocket (socketPath)
// #### @socketPath {string} Path to increment from
// Gets the next socket path in sequence from the
// specified `socketPath`.
//
exports.nextSocket = function (socketPath) {
const dir = path.dirname(socketPath),
name = path.basename(socketPath, '.sock'),
match = name.match(/^([a-zA-z]+)(\d*)$/i),
base = match[1];
let index = parseInt(match[2]);
if (isNaN(index)) {
index = 0;
}
index += 1;
return path.join(dir, base + index + '.sock');
};
/**
* @desc List of internal hostnames provided by your machine. A user
* provided hostname may also be provided when calling portfinder.getPort,
* which would then be added to the default hosts we lookup and return here.
*
* @return {array}
*
* Long Form Explantion:
*
* - Input: (os.networkInterfaces() w/ MacOS 10.11.5+ and running a VM)
*
* { lo0:
* [ { address: '::1',
* netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
* family: 'IPv6',
* mac: '00:00:00:00:00:00',
* scopeid: 0,
* internal: true },
* { address: '127.0.0.1',
* netmask: '255.0.0.0',
* family: 'IPv4',
* mac: '00:00:00:00:00:00',
* internal: true },
* { address: 'fe80::1',
* netmask: 'ffff:ffff:ffff:ffff::',
* family: 'IPv6',
* mac: '00:00:00:00:00:00',
* scopeid: 1,
* internal: true } ],
* en0:
* [ { address: 'fe80::a299:9bff:fe17:766d',
* netmask: 'ffff:ffff:ffff:ffff::',
* family: 'IPv6',
* mac: 'a0:99:9b:17:76:6d',
* scopeid: 4,
* internal: false },
* { address: '10.0.1.22',
* netmask: '255.255.255.0',
* family: 'IPv4',
* mac: 'a0:99:9b:17:76:6d',
* internal: false } ],
* awdl0:
* [ { address: 'fe80::48a8:37ff:fe34:aaef',
* netmask: 'ffff:ffff:ffff:ffff::',
* family: 'IPv6',
* mac: '4a:a8:37:34:aa:ef',
* scopeid: 8,
* internal: false } ],
* vnic0:
* [ { address: '10.211.55.2',
* netmask: '255.255.255.0',
* family: 'IPv4',
* mac: '00:1c:42:00:00:08',
* internal: false } ],
* vnic1:
* [ { address: '10.37.129.2',
* netmask: '255.255.255.0',
* family: 'IPv4',
* mac: '00:1c:42:00:00:09',
* internal: false } ] }
*
* - Output:
*
* [
* '0.0.0.0',
* '::1',
* '127.0.0.1',
* 'fe80::1',
* '10.0.1.22',
* 'fe80::48a8:37ff:fe34:aaef',
* '10.211.55.2',
* '10.37.129.2'
* ]
*
* Note we export this so we can use it in our tests, otherwise this API is private
*/
exports._defaultHosts = (function() {
let interfaces = {};
try{
interfaces = os.networkInterfaces();
}
catch(e) {
// As of October 2016, Windows Subsystem for Linux (WSL) does not support
// the os.networkInterfaces() call and throws instead. For this platform,
// assume 0.0.0.0 as the only address
//
// - https://github.com/Microsoft/BashOnWindows/issues/468
//
// - Workaround is a mix of good work from the community:
// - https://github.com/http-party/node-portfinder/commit/8d7e30a648ff5034186551fa8a6652669dec2f2f
// - https://github.com/yarnpkg/yarn/pull/772/files
if (e.syscall === 'uv_interface_addresses') {
// swallow error because we're just going to use defaults
// documented @ https://github.com/nodejs/node/blob/4b65a65e75f48ff447cabd5500ce115fb5ad4c57/doc/api/net.md#L231
} else {
throw e;
}
}
const interfaceNames = Object.keys(interfaces),
hiddenButImportantHost = '0.0.0.0', // !important - dont remove, hence the naming :)
results = [hiddenButImportantHost];
for (let i = 0; i < interfaceNames.length; i++) {
const _interface = interfaces[interfaceNames[i]];
for (let j = 0; j < _interface.length; j++) {
const curr = _interface[j];
results.push(curr.address);
}
}
// add null value, For createServer function, do not use host.
results.push(null);
debugDefaultHosts("exports._defaultHosts is: %o", results);
return results;
}());

34
app_vue/node_modules/portfinder/package.json generated vendored Normal file
View File

@ -0,0 +1,34 @@
{
"name": "portfinder",
"description": "A simple tool to find an open port on the current machine",
"version": "1.0.37",
"author": "Charlie Robbins <charlie.robbins@gmail.com>, Erik Trom <erik.trom@gmail.com>",
"repository": {
"type": "git",
"url": "git@github.com:http-party/node-portfinder.git"
},
"keywords": [
"http",
"ports",
"utilities"
],
"files": [
"lib"
],
"dependencies": {
"async": "^3.2.6",
"debug": "^4.3.6"
},
"devDependencies": {
"jest": "^29.7.0"
},
"main": "./lib/portfinder",
"types": "./lib/portfinder.d.ts",
"scripts": {
"test": "jest --runInBand"
},
"engines": {
"node": ">= 10.12"
},
"license": "MIT"
}