@push.rocks/smartproxy 22.4.2 → 22.6.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.
- package/changelog.md +28 -0
- package/dist_rust/rustproxy +0 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/index.d.ts +1 -5
- package/dist_ts/index.js +3 -9
- package/dist_ts/protocols/common/fragment-handler.js +5 -1
- package/dist_ts/proxies/index.d.ts +1 -5
- package/dist_ts/proxies/index.js +2 -6
- package/dist_ts/proxies/smart-proxy/index.d.ts +5 -10
- package/dist_ts/proxies/smart-proxy/index.js +7 -13
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +5 -2
- package/dist_ts/proxies/smart-proxy/route-preprocessor.d.ts +37 -0
- package/dist_ts/proxies/smart-proxy/route-preprocessor.js +103 -0
- package/dist_ts/proxies/smart-proxy/rust-binary-locator.d.ts +23 -0
- package/dist_ts/proxies/smart-proxy/rust-binary-locator.js +104 -0
- package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.d.ts +74 -0
- package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.js +146 -0
- package/dist_ts/proxies/smart-proxy/rust-proxy-bridge.d.ts +49 -0
- package/dist_ts/proxies/smart-proxy/rust-proxy-bridge.js +259 -0
- package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +39 -157
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +224 -621
- package/dist_ts/proxies/smart-proxy/socket-handler-server.d.ts +45 -0
- package/dist_ts/proxies/smart-proxy/socket-handler-server.js +253 -0
- package/dist_ts/routing/index.d.ts +1 -1
- package/dist_ts/routing/index.js +3 -3
- package/dist_ts/routing/models/http-types.d.ts +119 -4
- package/dist_ts/routing/models/http-types.js +93 -5
- package/package.json +1 -1
- package/readme.md +470 -219
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +4 -12
- package/ts/protocols/common/fragment-handler.ts +4 -0
- package/ts/proxies/index.ts +1 -9
- package/ts/proxies/smart-proxy/index.ts +6 -13
- package/ts/proxies/smart-proxy/models/interfaces.ts +6 -4
- package/ts/proxies/smart-proxy/route-preprocessor.ts +122 -0
- package/ts/proxies/smart-proxy/rust-binary-locator.ts +112 -0
- package/ts/proxies/smart-proxy/rust-metrics-adapter.ts +161 -0
- package/ts/proxies/smart-proxy/rust-proxy-bridge.ts +310 -0
- package/ts/proxies/smart-proxy/smart-proxy.ts +282 -798
- package/ts/proxies/smart-proxy/socket-handler-server.ts +279 -0
- package/ts/routing/index.ts +2 -2
- package/ts/routing/models/http-types.ts +147 -4
- package/ts/proxies/http-proxy/connection-pool.ts +0 -228
- package/ts/proxies/http-proxy/context-creator.ts +0 -145
- package/ts/proxies/http-proxy/default-certificates.ts +0 -150
- package/ts/proxies/http-proxy/function-cache.ts +0 -279
- package/ts/proxies/http-proxy/handlers/index.ts +0 -5
- package/ts/proxies/http-proxy/http-proxy.ts +0 -669
- package/ts/proxies/http-proxy/http-request-handler.ts +0 -331
- package/ts/proxies/http-proxy/http2-request-handler.ts +0 -255
- package/ts/proxies/http-proxy/index.ts +0 -18
- package/ts/proxies/http-proxy/models/http-types.ts +0 -148
- package/ts/proxies/http-proxy/models/index.ts +0 -5
- package/ts/proxies/http-proxy/models/types.ts +0 -125
- package/ts/proxies/http-proxy/request-handler.ts +0 -878
- package/ts/proxies/http-proxy/security-manager.ts +0 -413
- package/ts/proxies/http-proxy/websocket-handler.ts +0 -581
- package/ts/proxies/smart-proxy/acme-state-manager.ts +0 -112
- package/ts/proxies/smart-proxy/cert-store.ts +0 -92
- package/ts/proxies/smart-proxy/certificate-manager.ts +0 -895
- package/ts/proxies/smart-proxy/connection-manager.ts +0 -809
- package/ts/proxies/smart-proxy/http-proxy-bridge.ts +0 -213
- package/ts/proxies/smart-proxy/metrics-collector.ts +0 -453
- package/ts/proxies/smart-proxy/nftables-manager.ts +0 -271
- package/ts/proxies/smart-proxy/port-manager.ts +0 -358
- package/ts/proxies/smart-proxy/route-connection-handler.ts +0 -1712
- package/ts/proxies/smart-proxy/route-orchestrator.ts +0 -297
- package/ts/proxies/smart-proxy/security-manager.ts +0 -269
- package/ts/proxies/smart-proxy/throughput-tracker.ts +0 -138
- package/ts/proxies/smart-proxy/timeout-manager.ts +0 -196
- package/ts/proxies/smart-proxy/tls-manager.ts +0 -171
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import * as plugins from '../../plugins.js';
|
|
2
|
-
import { AsyncFileSystem } from '../../core/utils/fs-utils.js';
|
|
3
|
-
import type { ICertificateData } from './certificate-manager.js';
|
|
4
|
-
|
|
5
|
-
export class CertStore {
|
|
6
|
-
constructor(private certDir: string) {}
|
|
7
|
-
|
|
8
|
-
public async initialize(): Promise<void> {
|
|
9
|
-
await AsyncFileSystem.ensureDir(this.certDir);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public async getCertificate(routeName: string): Promise<ICertificateData | null> {
|
|
13
|
-
const certPath = this.getCertPath(routeName);
|
|
14
|
-
const metaPath = `${certPath}/meta.json`;
|
|
15
|
-
|
|
16
|
-
if (!await AsyncFileSystem.exists(metaPath)) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
const meta = await AsyncFileSystem.readJSON(metaPath);
|
|
22
|
-
|
|
23
|
-
const [cert, key] = await Promise.all([
|
|
24
|
-
AsyncFileSystem.readFile(`${certPath}/cert.pem`),
|
|
25
|
-
AsyncFileSystem.readFile(`${certPath}/key.pem`)
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
let ca: string | undefined;
|
|
29
|
-
const caPath = `${certPath}/ca.pem`;
|
|
30
|
-
if (await AsyncFileSystem.exists(caPath)) {
|
|
31
|
-
ca = await AsyncFileSystem.readFile(caPath);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
cert,
|
|
36
|
-
key,
|
|
37
|
-
ca,
|
|
38
|
-
expiryDate: new Date(meta.expiryDate),
|
|
39
|
-
issueDate: new Date(meta.issueDate)
|
|
40
|
-
};
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error(`Failed to load certificate for ${routeName}: ${error}`);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public async saveCertificate(
|
|
48
|
-
routeName: string,
|
|
49
|
-
certData: ICertificateData
|
|
50
|
-
): Promise<void> {
|
|
51
|
-
const certPath = this.getCertPath(routeName);
|
|
52
|
-
await AsyncFileSystem.ensureDir(certPath);
|
|
53
|
-
|
|
54
|
-
// Save certificate files in parallel
|
|
55
|
-
const savePromises = [
|
|
56
|
-
AsyncFileSystem.writeFile(`${certPath}/cert.pem`, certData.cert),
|
|
57
|
-
AsyncFileSystem.writeFile(`${certPath}/key.pem`, certData.key)
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
if (certData.ca) {
|
|
61
|
-
savePromises.push(
|
|
62
|
-
AsyncFileSystem.writeFile(`${certPath}/ca.pem`, certData.ca)
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Save metadata
|
|
67
|
-
const meta = {
|
|
68
|
-
expiryDate: certData.expiryDate.toISOString(),
|
|
69
|
-
issueDate: certData.issueDate.toISOString(),
|
|
70
|
-
savedAt: new Date().toISOString()
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
savePromises.push(
|
|
74
|
-
AsyncFileSystem.writeJSON(`${certPath}/meta.json`, meta)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
await Promise.all(savePromises);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public async deleteCertificate(routeName: string): Promise<void> {
|
|
81
|
-
const certPath = this.getCertPath(routeName);
|
|
82
|
-
if (await AsyncFileSystem.isDirectory(certPath)) {
|
|
83
|
-
await AsyncFileSystem.removeDir(certPath);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private getCertPath(routeName: string): string {
|
|
88
|
-
// Sanitize route name for filesystem
|
|
89
|
-
const safeName = routeName.replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
90
|
-
return `${this.certDir}/${safeName}`;
|
|
91
|
-
}
|
|
92
|
-
}
|