mirror of
https://github.com/hzrd149/nsite-gateway.git
synced 2025-06-23 20:05:03 +00:00
14 lines
373 B
TypeScript
14 lines
373 B
TypeScript
import { ClientOptions, WebSocket } from "ws";
|
|
import { ClientRequestArgs } from "http";
|
|
|
|
import agent from "./proxy.js";
|
|
|
|
class ProxyWebSocket extends WebSocket {
|
|
constructor(address: string | URL, options?: ClientOptions | ClientRequestArgs) {
|
|
super(address, { agent, ...options });
|
|
}
|
|
}
|
|
|
|
// @ts-expect-error
|
|
global.WebSocket = agent ? ProxyWebSocket : WebSocket;
|