@push.rocks/smartproxy 3.23.1 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '3.23.1',
6
+ version: '3.25.0',
7
7
  description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, and dynamic routing with authentication options.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLDRMQUE0TDtDQUMxTSxDQUFBIn0=
@@ -2,30 +2,112 @@ import * as plugins from './plugins.js';
2
2
  import { ProxyRouter } from './classes.router.js';
3
3
  export interface INetworkProxyOptions {
4
4
  port: number;
5
+ maxConnections?: number;
6
+ keepAliveTimeout?: number;
7
+ headersTimeout?: number;
8
+ logLevel?: 'error' | 'warn' | 'info' | 'debug';
9
+ cors?: {
10
+ allowOrigin?: string;
11
+ allowMethods?: string;
12
+ allowHeaders?: string;
13
+ maxAge?: number;
14
+ };
5
15
  }
6
16
  export declare class NetworkProxy {
7
17
  options: INetworkProxyOptions;
8
18
  proxyConfigs: plugins.tsclass.network.IReverseProxyConfig[];
9
- httpsServer: plugins.https.Server;
10
- router: ProxyRouter;
11
- socketMap: plugins.lik.ObjectMap<plugins.net.Socket>;
12
19
  defaultHeaders: {
13
20
  [key: string]: string;
14
21
  };
15
- heartbeatInterval: NodeJS.Timeout;
22
+ httpsServer: plugins.https.Server;
23
+ wsServer: plugins.ws.WebSocketServer;
24
+ router: ProxyRouter;
25
+ socketMap: plugins.lik.ObjectMap<plugins.net.Socket>;
26
+ activeContexts: Set<string>;
27
+ connectedClients: number;
28
+ startTime: number;
29
+ requestsServed: number;
30
+ failedRequests: number;
31
+ private heartbeatInterval;
32
+ private metricsInterval;
16
33
  private defaultCertificates;
17
- alreadyAddedReverseConfigs: {
18
- [hostName: string]: plugins.tsclass.network.IReverseProxyConfig;
19
- };
34
+ private certificateCache;
35
+ /**
36
+ * Creates a new NetworkProxy instance
37
+ */
20
38
  constructor(optionsArg: INetworkProxyOptions);
39
+ /**
40
+ * Loads default certificates from the filesystem
41
+ */
42
+ private loadDefaultCertificates;
43
+ /**
44
+ * Starts the proxy server
45
+ */
21
46
  start(): Promise<void>;
22
47
  /**
23
- * Internal async handler for processing HTTP/HTTPS requests.
48
+ * Sets up tracking of TCP connections
49
+ */
50
+ private setupConnectionTracking;
51
+ /**
52
+ * Sets up WebSocket support
53
+ */
54
+ private setupWebsocketSupport;
55
+ /**
56
+ * Sets up metrics collection
57
+ */
58
+ private setupMetricsCollection;
59
+ /**
60
+ * Handles an incoming WebSocket connection
61
+ */
62
+ private handleWebSocketConnection;
63
+ /**
64
+ * Handles an HTTP/HTTPS request
24
65
  */
25
66
  private handleRequest;
67
+ /**
68
+ * Handles a CORS preflight request
69
+ */
70
+ private handleCorsRequest;
71
+ /**
72
+ * Authenticates a request against the destination config
73
+ */
74
+ private authenticateRequest;
75
+ /**
76
+ * Forwards a request to the destination
77
+ */
78
+ private forwardRequest;
79
+ /**
80
+ * Prepares headers to forward to the backend
81
+ */
82
+ private prepareForwardHeaders;
83
+ /**
84
+ * Sets up request streaming for the proxy
85
+ */
86
+ private setupRequestStreaming;
87
+ /**
88
+ * Processes a proxy response
89
+ */
90
+ private processProxyResponse;
91
+ /**
92
+ * Sends an error response to the client
93
+ */
94
+ private sendErrorResponse;
95
+ /**
96
+ * Updates proxy configurations
97
+ */
26
98
  updateProxyConfigs(proxyConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]): Promise<void>;
99
+ /**
100
+ * Adds default headers to be included in all responses
101
+ */
27
102
  addDefaultHeaders(headersArg: {
28
103
  [key: string]: string;
29
104
  }): Promise<void>;
105
+ /**
106
+ * Stops the proxy server
107
+ */
30
108
  stop(): Promise<void>;
109
+ /**
110
+ * Logs a message according to the configured log level
111
+ */
112
+ private log;
31
113
  }