@xmobitea/gn-server
Version:
GearN Server by XmobiTea (Pro)
77 lines (76 loc) • 4.68 kB
TypeScript
import express from "express";
import { Socket } from "socket.io";
import * as mongoDB from "mongodb";
export declare class AntiDdosMiddleware {
private static readonly FIVE_MINUTE_TS;
private static readonly K_MULTIPLE_WHITE_LIST;
private static readonly K_MULTIPLE_BLACK_LIST;
private socketRequestPerIPDic;
private socketRequestPerPeerDic;
private httpRequestPerIPDic;
private httpRequestPerPeerDic;
private currentHttpRequestCount;
private currentSocketRequestCount;
private currentHttpUploadRequestCount;
private currentHttpDownloadRequestCount;
private reportDdosCollection;
private banDdosCollection;
private socketMaxRequestPerSecondPerIp;
private socketMaxRequestPerSecondPerPeer;
private socketMaxPendingRequest;
private socketMaxRequestSize;
private httpMaxRequestPerSecondPerIp;
private httpMaxRequestPerSecondPerPeer;
private httpMaxPendingRequest;
private httpMaxRequestSize;
private maxUploadPendingRequest;
private maxDownloadPendingRequest;
private defaultIPWhiteLst;
private ipWhiteLst;
private ipBlackLst;
setReportDdosCollection(reportDdosCollection: mongoDB.Collection<mongoDB.Document>): void;
setBanDdosCollection(banDdosCollection: mongoDB.Collection<mongoDB.Document>): void;
setSocketMaxRequestPerSecondPerIp(socketMaxRequestPerSecondPerIp: number): void;
setSocketMaxRequestPerSecondPerPeer(socketMaxRequestPerSecondPerPeer: number): void;
setSocketMaxPendingRequest(socketMaxPendingRequest: number): void;
setSocketMaxRequestSize(socketMaxRequestSize: number): void;
setHttpMaxRequestPerSecondPerIp(httpMaxRequestPerSecondPerIp: number): void;
setHttpMaxRequestPerSecondPerPeer(httpMaxRequestPerSecondPerPeer: number): void;
setHttpMaxPendingRequest(httpMaxPendingRequest: number): void;
setHttpMaxRequestSize(httpMaxRequestSize: number): void;
setMaxUploadPendingRequest(maxUploadPendingRequest: number): void;
setMaxDownloadPendingRequest(maxDownloadPendingRequest: number): void;
setIPWhiteList(ipWhiteList: string[]): void;
checkRequestSizeBodyViaJson(req: express.Request, res: express.Response, next: Function): Promise<any>;
checkRequestSizeBodyViaMsgPack(req: express.Request, res: express.Response, next: Function): Promise<any>;
private getReturnCodeForRequestSizeHttp;
checkRequestSizeBodyViaSocketMsgPack(socket: Socket, data: any, next: Function): Promise<any>;
checkRequestSizeBodyViaSocketJson(socket: Socket, data: any, next: Function): Promise<any>;
checkMaxRequestPerSecondPerIpViaSocket(socket: Socket, data: any, next: Function): Promise<any>;
checkMaxRequestPerSecondPerPeerViaSocket(socket: Socket, data: any, next: Function): Promise<any>;
checkMaxRequestPerSecondPerIpViaJson(req: express.Request, res: express.Response, next: Function): Promise<any>;
checkMaxUploadRequestPerSecondPerIp(req: express.Request, res: express.Response, next: Function): Promise<any>;
checkMaxRequestPerSecondPerIpViaMsgPack(req: express.Request, res: express.Response, next: Function): Promise<any>;
private getReturnCodeForMaxRequestPerSecondPerIp;
checkMaxRequestPerSecondPerPeerViaJson(req: express.Request, res: express.Response, next: Function): Promise<any>;
checkMaxUploadRequestPerSecondPerPeer(req: express.Request, res: express.Response, next: Function): Promise<any>;
checkMaxRequestPerSecondPerPeerViaMsgPack(req: express.Request, res: express.Response, next: Function): Promise<any>;
private getReturnCodeForMaxRequestPerSecondPerPeer;
addPendingRequestViaJson(req: express.Request, res: express.Response, next: Function): Promise<any>;
addPendingRequestViaMsgPack(req: express.Request, res: express.Response, next: Function): Promise<any>;
private getReturnCodeForPendingRequest;
removePendingRequest(req: express.Request, res: express.Response): void;
addPendingUploadRequest(req: express.Request, res: express.Response, next: Function): Promise<any>;
removePendingUploadRequest(req: express.Request, res: express.Response): void;
addPendingRequestViaSocket(socket: Socket, data: any, next: Function): any;
removePendingRequestViaSocket(socket: Socket, data: any): void;
addPendingDownloadRequest(req: express.Request, res: express.Response, next: Function): Promise<any>;
removePendingDownloadRequest(req: express.Request, res: express.Response): void;
run(): void;
private getBanDdos;
private clearHttpRequestPerIPDic;
private clearHttpRequestPerPeerDic;
private clearSocketRequestPerIPDic;
private clearSocketRequestPerPeerDic;
constructor();
}