我的node项目首次提交!!!
This commit is contained in:
50
node_modules/@fastify/proxy-addr/benchmark/compiling.js
generated
vendored
Normal file
50
node_modules/@fastify/proxy-addr/benchmark/compiling.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Globals for benchmark.js
|
||||
*/
|
||||
global.proxyaddr = require('..')
|
||||
global.createReq = createReq
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
const benchmark = require('benchmark')
|
||||
const benchmarks = require('beautify-benchmark')
|
||||
|
||||
const suite = new benchmark.Suite()
|
||||
|
||||
suite.add({
|
||||
name: 're-compiling',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, "loopback")',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1")'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'pre-compiling',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = proxyaddr.compile("loopback")'
|
||||
})
|
||||
|
||||
suite.on('cycle', function onCycle (event) {
|
||||
benchmarks.add(event.target)
|
||||
})
|
||||
|
||||
suite.on('complete', function onComplete () {
|
||||
benchmarks.log()
|
||||
})
|
||||
|
||||
suite.run({ async: false })
|
||||
|
||||
function createReq (socketAddr, forwardedFor) {
|
||||
return {
|
||||
socket: {
|
||||
remoteAddress: socketAddr
|
||||
},
|
||||
headers: {
|
||||
'x-forwarded-for': (forwardedFor || '')
|
||||
}
|
||||
}
|
||||
}
|
||||
30
node_modules/@fastify/proxy-addr/benchmark/index.js
generated
vendored
Normal file
30
node_modules/@fastify/proxy-addr/benchmark/index.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const spawn = require('node:child_process').spawn
|
||||
|
||||
const exe = process.argv[0]
|
||||
const cwd = process.cwd()
|
||||
|
||||
runScripts(fs.readdirSync(__dirname))
|
||||
|
||||
function runScripts (fileNames) {
|
||||
const fileName = fileNames.shift()
|
||||
|
||||
if (!fileName) return
|
||||
if (!/\.js$/i.test(fileName)) return runScripts(fileNames)
|
||||
if (fileName.toLowerCase() === 'index.js') return runScripts(fileNames)
|
||||
|
||||
const fullPath = path.join(__dirname, fileName)
|
||||
|
||||
console.log('> %s %s', exe, path.relative(cwd, fullPath))
|
||||
|
||||
const proc = spawn(exe, [fullPath], {
|
||||
stdio: 'inherit'
|
||||
})
|
||||
|
||||
proc.on('exit', function () {
|
||||
runScripts(fileNames)
|
||||
})
|
||||
}
|
||||
57
node_modules/@fastify/proxy-addr/benchmark/kind.js
generated
vendored
Normal file
57
node_modules/@fastify/proxy-addr/benchmark/kind.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Globals for benchmark.js
|
||||
*/
|
||||
global.proxyaddr = require('..')
|
||||
global.createReq = createReq
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
const benchmark = require('benchmark')
|
||||
const benchmarks = require('beautify-benchmark')
|
||||
|
||||
const suite = new benchmark.Suite()
|
||||
|
||||
suite.add({
|
||||
name: 'ipv4',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = proxyaddr.compile("127.0.0.1")'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'ipv4-mapped',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("::ffff:7f00:1", "10.0.0.1"); trust = proxyaddr.compile("127.0.0.1")'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'ipv6',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("::1", "10.0.0.1"); trust = proxyaddr.compile("::1")'
|
||||
})
|
||||
|
||||
suite.on('cycle', function onCycle (event) {
|
||||
benchmarks.add(event.target)
|
||||
})
|
||||
|
||||
suite.on('complete', function onComplete () {
|
||||
benchmarks.log()
|
||||
})
|
||||
|
||||
suite.run({ async: false })
|
||||
|
||||
function createReq (socketAddr, forwardedFor) {
|
||||
return {
|
||||
socket: {
|
||||
remoteAddress: socketAddr
|
||||
},
|
||||
headers: {
|
||||
'x-forwarded-for': (forwardedFor || '')
|
||||
}
|
||||
}
|
||||
}
|
||||
78
node_modules/@fastify/proxy-addr/benchmark/matching.js
generated
vendored
Normal file
78
node_modules/@fastify/proxy-addr/benchmark/matching.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Globals for benchmark.js
|
||||
*/
|
||||
global.proxyaddr = require('..')
|
||||
global.createReq = createReq
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
const benchmark = require('benchmark')
|
||||
const benchmarks = require('beautify-benchmark')
|
||||
|
||||
const suite = new benchmark.Suite()
|
||||
|
||||
suite.add({
|
||||
name: 'trust none',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = proxyaddr.compile([])'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'trust all',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = function() {return true}'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'trust single',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = proxyaddr.compile("127.0.0.1")'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'trust first',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = function(a, i) {return i<1}'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'trust subnet',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = proxyaddr.compile("127.0.0.1/8")'
|
||||
})
|
||||
|
||||
suite.add({
|
||||
name: 'trust multiple',
|
||||
minSamples: 100,
|
||||
fn: 'proxyaddr(req, trust)',
|
||||
setup: 'req = createReq("127.0.0.1", "10.0.0.1"); trust = proxyaddr.compile(["127.0.0.1", "10.0.0.1"])'
|
||||
})
|
||||
|
||||
suite.on('cycle', function onCycle (event) {
|
||||
benchmarks.add(event.target)
|
||||
})
|
||||
|
||||
suite.on('complete', function onComplete () {
|
||||
benchmarks.log()
|
||||
})
|
||||
|
||||
suite.run({ async: false })
|
||||
|
||||
function createReq (socketAddr, forwardedFor) {
|
||||
return {
|
||||
socket: {
|
||||
remoteAddress: socketAddr
|
||||
},
|
||||
headers: {
|
||||
'x-forwarded-for': (forwardedFor || '')
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user