diff --git a/packages/monitor/src/Storage.ts b/packages/monitor/src/Storage.ts index cb609e24b..eb165b11a 100644 --- a/packages/monitor/src/Storage.ts +++ b/packages/monitor/src/Storage.ts @@ -16,7 +16,7 @@ export class Storage extends EventEmitter { * Get all constant values. */ async all(): Promise { - const data: Array<{key: String, value: any}> = [] + const data: Array<{key: string, value: any}> = [] this.constant.forEach((value, key) => data.push({ key, value })) return data } diff --git a/packages/server/src/Connection.ts b/packages/server/src/Connection.ts index 3f05d7414..35f91b72a 100644 --- a/packages/server/src/Connection.ts +++ b/packages/server/src/Connection.ts @@ -27,7 +27,7 @@ class Connection { onClose: (document: Document) => null, } - socketId: String + socketId: string lock: AsyncLock @@ -39,7 +39,7 @@ class Connection { request: HTTPIncomingMessage, document: Document, timeout: number, - socketId: String, + socketId: string, context: any, ) { this.connection = connection diff --git a/packages/server/src/Hocuspocus.ts b/packages/server/src/Hocuspocus.ts index 2c4a9b982..84e2ef17d 100644 --- a/packages/server/src/Hocuspocus.ts +++ b/packages/server/src/Hocuspocus.ts @@ -37,9 +37,9 @@ export class Hocuspocus { documents = new Map() - connectionsByIp: Map> = new Map() + connectionsByIp: Map> = new Map() - bannedIps: Map = new Map() + bannedIps: Map = new Map() httpServer?: HTTPServer @@ -150,12 +150,12 @@ export class Hocuspocus { handleConnection(incoming: WebSocket, request: IncomingMessage, context: any = null): void { // get the remote ip address - const ip = request.headers['x-real-ip'] + const ip = request.headers['x-real-ip'] || request.headers['x-forwarded-for'] || request.socket.remoteAddress || '' // throttle the connection - if (this.throttle(ip)) { + if (this.throttle( ip)) { return incoming.close() } @@ -193,7 +193,7 @@ export class Hocuspocus { * Handle update of the given document * @private */ - private handleDocumentUpdate(document: Document, connection: Connection, update: Uint8Array, request: IncomingMessage, socketId: String): void { + private handleDocumentUpdate(document: Document, connection: Connection, update: Uint8Array, request: IncomingMessage, socketId: string): void { const hookPayload = { clientsCount: document.connectionsCount(), @@ -256,7 +256,7 @@ export class Hocuspocus { * Create a new connection by the given request and document * @private */ - private createConnection(connection: WebSocket, request: IncomingMessage, document: Document, socketId: String, context?: any): Connection { + private createConnection(connection: WebSocket, request: IncomingMessage, document: Document, socketId: string, context?: any): Connection { const instance = new Connection(connection, request, document, this.configuration.timeout, socketId, context) @@ -326,7 +326,7 @@ export class Hocuspocus { * Throttle requests * @private */ - private throttle(ip: String): Boolean { + private throttle(ip: string): Boolean { if (!this.configuration.throttle) { return false }