fatsify核心功能示例测试!!!

This commit is contained in:
2025-09-21 14:50:41 +08:00
commit 9145aea047
1958 changed files with 230098 additions and 0 deletions

23
node_modules/@fastify/forwarded/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
(The MIT License)
Copyright (c) 2021 Fastify collaborators
Copyright (c) 2014-2017 Douglas Christopher Wilson
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.

43
node_modules/@fastify/forwarded/README.md generated vendored Normal file
View File

@@ -0,0 +1,43 @@
# @fastify/forwarded
![CI](https://github.com/fastify/forwarded/workflows/CI/badge.svg)
[![NPM version](https://img.shields.io/npm/v/@fastify/forwarded.svg?style=flat)](https://www.npmjs.com/package/@fastify/forwarded)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
Parse HTTP X-Forwarded-For header.
Updated version of the great https://github.com/jshttp/forwarded.
Implements https://github.com/jshttp/forwarded/pull/9.
## Installation
```sh
$ npm i @fastify/forwarded
```
## API
```js
var forwarded = require('@fastify/forwarded')
```
### forwarded(req)
```js
var addresses = forwarded(req)
```
Parse the `X-Forwarded-For` header from the request. Returns an array
of the addresses, including the socket address for the `req`, in reverse
order (i.e. index `0` is the socket address and the last index is the
furthest address, typically the end-user).
## Testing
```sh
$ npm test
```
## License
[MIT](LICENSE)

59
node_modules/@fastify/forwarded/index.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
/*!
* forwarded
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict'
/**
* Get all addresses in the request used in the `X-Forwarded-For` header.
*/
function forwarded (req) {
if (!req) {
throw new TypeError('argument req is required')
}
const header = req.headers['x-forwarded-for']
const socketAddr = req.socket.remoteAddress
if (!header || typeof header !== 'string') {
return [socketAddr]
} else if (header.indexOf(',') === -1) {
const remote = header.trim()
return (remote.length)
? [socketAddr, remote]
: [socketAddr]
} else {
return parse(header, socketAddr)
}
}
function parse (header, socketAddr) {
const result = [socketAddr]
let end = header.length
let start = end
let char
let i
for (i = end - 1; i >= 0; --i) {
char = header[i]
if (char === ' ') {
(start === end) && (start = end = i)
} else if (char === ',') {
(start !== end) && result.push(header.slice(start, end))
start = end = i
} else {
start = i
}
}
(start !== end) && result.push(header.substring(start, end))
return result
}
module.exports = forwarded
module.exports.default = forwarded
module.exports.forwarded = forwarded

48
node_modules/@fastify/forwarded/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "@fastify/forwarded",
"description": "Parse HTTP X-Forwarded-For header",
"version": "3.0.0",
"type": "commonjs",
"contributors": [
"Matteo Collina <hello@matteocollina.com>",
"Douglas Christopher Wilson <doug@somethingdoug.com>",
"Aras Abbasi <aras.abbasi@gmail.com"
],
"license": "MIT",
"keywords": [
"x-forwarded-for",
"http",
"req"
],
"repository": {
"type": "git",
"url": "git+https://github.com/fastify/forwarded.git"
},
"bugs": {
"url": "https://github.com/fastify/forwarded/issues"
},
"homepage": "https://github.com/fastify/forwarded#readme",
"devDependencies": {
"@types/node": "^20.14.9",
"benchmark": "2.1.4",
"standard": "^17.1.0",
"tap": "^18.8.0",
"tsd": "^0.31.1"
},
"types": "types/index.d.ts",
"files": [
"LICENSE",
"README.md",
"index.js",
"types/index.d.ts"
],
"scripts": {
"bench": "node benchmark/index.js",
"bench:combined": "node benchmark/combined.js",
"lint": "standard",
"lint:fix": "standard --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:typescript": "tsd"
}
}

14
node_modules/@fastify/forwarded/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { IncomingMessage } from 'http';
type Forwarded = (req: IncomingMessage) => string[]
declare namespace forwarded {
export const forwarded: Forwarded
export { forwarded as default }
}
/**
* Get all addresses in the request used in the `X-Forwarded-For` header.
*/
declare function forwarded(...params: Parameters<Forwarded>): ReturnType<Forwarded>
export = forwarded