kaven-utils
Version:
Utils for Node.js.
43 lines (42 loc) • 1.35 kB
JavaScript
/********************************************************************
* @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: 2025-10-14 22:58:04.862
* @version: 6.1.0
* @times: 28
* @lines: 53
* @copyright: Copyright © 2022-2025 Kaven. All Rights Reserved.
* @description: [description]
* @license: [license]
********************************************************************/
import { HttpRequestParser } from "../http/HttpRequestParser.js";
export class HttpProxyUser {
StartDate;
UserSocket;
User;
Logger;
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(data) {
this.Logger?.Info(`[${this.User} -> ${this.Server}]${data}`);
}
Error(data) {
this.Logger?.Error(`[${this.User} -> ${this.Server}]${data}`);
}
Destroy() {
this.UserSocket.destroy();
this.ServerSocket?.destroy();
}
}