UNPKG

kaven-utils

Version:

Utils for Node.js.

43 lines (42 loc) 1.43 kB
/******************************************************************** * @author: Kaven * @email: kaven@wuwenkai.com * @website: http://blog.kaven.xyz * @file: [Kaven-Utils] /src/net/proxy/HttpProxyUser.ts * @create: 2022-04-12 13:15:31.858 * @modify: 2024-11-01 10:48:07.312 * @version: 5.4.5 * @times: 24 * @lines: 51 * @copyright: Copyright © 2022-2024 Kaven. All Rights Reserved. * @description: [description] * @license: [license] ********************************************************************/ import { HttpRequestParser } from "../http/HttpRequestParser.js"; import { InternalLogger } from "../../KavenUtility.Internal.js"; export class HttpProxyUser { StartDate; UserSocket; User; constructor(userSocket) { this.StartDate = new Date(); this.UserSocket = userSocket; this.Parser = new HttpRequestParser(); const userIp = userSocket.remoteAddress; const userPort = userSocket.remotePort; this.User = `${userIp}:${userPort}`; } Parser; ServerSocket; Server = ""; Log(...args) { InternalLogger()?.Info(`[${this.User} -> ${this.Server}]`, ...args); } Error(...args) { InternalLogger()?.Error(`[${this.User} -> ${this.Server}]`, ...args); } Destroy() { this.UserSocket.destroy(); this.ServerSocket?.destroy(); } }