@based/server
Advanced tools
Comparing version 6.0.2 to 6.1.0
@@ -16,3 +16,2 @@ "use strict"; | ||
const parseQuery_1 = __importDefault(require("./parseQuery")); | ||
const ip_1 = require("../../ip"); | ||
const auth_1 = require("../../auth"); | ||
@@ -37,3 +36,3 @@ const authorize_1 = require("../../authorize"); | ||
}); | ||
const ip = (0, ip_1.getIp)(res); | ||
const ip = server.getIp(res, req); | ||
if ((0, security_1.blockIncomingRequest)(server, ip, res, req, server.rateLimit.http, 1)) { | ||
@@ -40,0 +39,0 @@ return; |
@@ -6,3 +6,2 @@ "use strict"; | ||
const security_1 = require("../security"); | ||
const ip_1 = require("../ip"); | ||
// import { BasedErrorCode } from '../error' | ||
@@ -49,3 +48,3 @@ let clientId = 0; | ||
ctx) => { | ||
const ip = (0, ip_1.getIp)(res); | ||
const ip = server.getIp(res, req); | ||
if ((0, security_1.blockIncomingRequest)(server, ip, res, req, server.rateLimit.ws, 10)) { | ||
@@ -64,3 +63,3 @@ return; | ||
}); | ||
const ip = (0, ip_1.getIp)(res); | ||
const ip = server.getIp(res, req); | ||
if ((0, security_1.blockIncomingRequest)(server, ip, res, req, server.rateLimit.ws, 10)) { | ||
@@ -67,0 +66,0 @@ return; |
@@ -24,2 +24,3 @@ /// <reference types="node" /> | ||
}; | ||
type GetIp = (res: uws.HttpResponse, req: uws.HttpRequest) => string; | ||
export type ServerOptions = { | ||
@@ -49,2 +50,3 @@ clients?: { | ||
}; | ||
getIp?: GetIp; | ||
}; | ||
@@ -95,2 +97,3 @@ /** | ||
geo: (ctx: Context) => Promise<Geo>; | ||
getIp: GetIp; | ||
blockedIps: Set<string>; | ||
@@ -97,0 +100,0 @@ allowedIps: Set<string>; |
@@ -75,2 +75,5 @@ "use strict"; | ||
}; | ||
this.getIp = (res) => { | ||
return Buffer.from(res.getRemoteAddressAsText()).toString(); | ||
}; | ||
this.blockedIps = new Set(); | ||
@@ -109,2 +112,5 @@ // opposite of blockedIps can never get blocked | ||
} | ||
if (opts.getIp) { | ||
this.getIp = opts.getIp; | ||
} | ||
(0, incoming_1.default)(this, opts); | ||
@@ -111,0 +117,0 @@ } |
{ | ||
"name": "@based/server", | ||
"version": "6.0.2", | ||
"version": "6.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
439853
288
6639