rust-http-playback-proxy 0.4.1 → 0.4.3
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/LICENSE +21 -0
- package/bin/darwin-amd64/http-playback-proxy +0 -0
- package/bin/darwin-arm64/http-playback-proxy +0 -0
- package/bin/linux-amd64/http-playback-proxy +0 -0
- package/bin/linux-arm64/http-playback-proxy +0 -0
- package/dist/proxy.d.ts +1 -7
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +113 -110
- package/dist/proxy.js.map +1 -1
- package/dist/test/shutdown.test.d.ts +2 -0
- package/dist/test/shutdown.test.d.ts.map +1 -0
- package/dist/test/shutdown.test.js +115 -0
- package/dist/test/shutdown.test.js.map +1 -0
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kunihiko Miyanaga
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/proxy.d.ts
CHANGED
|
@@ -12,13 +12,9 @@ export declare class Proxy {
|
|
|
12
12
|
private process?;
|
|
13
13
|
constructor(mode: ProxyMode, port: number, inventoryDir: string, entryUrl?: string, deviceType?: string);
|
|
14
14
|
/**
|
|
15
|
-
* Get the actual port number
|
|
15
|
+
* Get the actual port number
|
|
16
16
|
*/
|
|
17
17
|
get port(): number;
|
|
18
|
-
/**
|
|
19
|
-
* Update the port number (used internally when OS assigns a port)
|
|
20
|
-
*/
|
|
21
|
-
updatePort(port: number): void;
|
|
22
18
|
/**
|
|
23
19
|
* Set the child process
|
|
24
20
|
*/
|
|
@@ -26,7 +22,6 @@ export declare class Proxy {
|
|
|
26
22
|
/**
|
|
27
23
|
* Stop the proxy gracefully
|
|
28
24
|
* Sends SIGTERM signal (cross-platform)
|
|
29
|
-
* Node.js automatically converts to appropriate signal on Windows (CTRL_BREAK)
|
|
30
25
|
*/
|
|
31
26
|
stop(): Promise<void>;
|
|
32
27
|
/**
|
|
@@ -39,7 +34,6 @@ export declare class Proxy {
|
|
|
39
34
|
wait(): Promise<void>;
|
|
40
35
|
/**
|
|
41
36
|
* Load the inventory for this proxy
|
|
42
|
-
* This is useful after recording is complete
|
|
43
37
|
*/
|
|
44
38
|
getInventory(): Promise<Inventory>;
|
|
45
39
|
}
|
package/dist/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"proxy.d.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EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK3G;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
package/dist/proxy.js
CHANGED
|
@@ -43,7 +43,58 @@ exports.getInventoryPath = getInventoryPath;
|
|
|
43
43
|
const child_process_1 = require("child_process");
|
|
44
44
|
const path = __importStar(require("path"));
|
|
45
45
|
const fs = __importStar(require("fs"));
|
|
46
|
+
const net = __importStar(require("net"));
|
|
46
47
|
const binary_1 = require("./binary");
|
|
48
|
+
/**
|
|
49
|
+
* Find an available port by binding to port 0 and releasing it
|
|
50
|
+
*/
|
|
51
|
+
async function getAvailablePort() {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const server = net.createServer();
|
|
54
|
+
server.listen(0, '127.0.0.1', () => {
|
|
55
|
+
const address = server.address();
|
|
56
|
+
if (address && typeof address === 'object') {
|
|
57
|
+
const port = address.port;
|
|
58
|
+
server.close(() => resolve(port));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
server.close(() => reject(new Error('Failed to get port from server address')));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
server.on('error', reject);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Wait for a port to become available (accepting connections)
|
|
69
|
+
* Uses TCP connection attempts with exponential backoff
|
|
70
|
+
*/
|
|
71
|
+
async function waitForPort(port, timeoutMs = 60000) {
|
|
72
|
+
const startTime = Date.now();
|
|
73
|
+
let delay = 50; // Start with 50ms delay
|
|
74
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
75
|
+
try {
|
|
76
|
+
await new Promise((resolve, reject) => {
|
|
77
|
+
const socket = net.createConnection({ port, host: '127.0.0.1' });
|
|
78
|
+
socket.on('connect', () => {
|
|
79
|
+
socket.destroy();
|
|
80
|
+
resolve();
|
|
81
|
+
});
|
|
82
|
+
socket.on('error', reject);
|
|
83
|
+
socket.setTimeout(1000, () => {
|
|
84
|
+
socket.destroy();
|
|
85
|
+
reject(new Error('Connection timeout'));
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
return; // Port is open
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Port not ready yet, wait and retry
|
|
92
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
93
|
+
delay = Math.min(delay * 1.5, 500); // Exponential backoff, max 500ms
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Timeout waiting for port ${port} to become available`);
|
|
97
|
+
}
|
|
47
98
|
/**
|
|
48
99
|
* Represents a running proxy instance
|
|
49
100
|
*/
|
|
@@ -56,17 +107,11 @@ class Proxy {
|
|
|
56
107
|
this.deviceType = deviceType;
|
|
57
108
|
}
|
|
58
109
|
/**
|
|
59
|
-
* Get the actual port number
|
|
110
|
+
* Get the actual port number
|
|
60
111
|
*/
|
|
61
112
|
get port() {
|
|
62
113
|
return this._port;
|
|
63
114
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Update the port number (used internally when OS assigns a port)
|
|
66
|
-
*/
|
|
67
|
-
updatePort(port) {
|
|
68
|
-
this._port = port;
|
|
69
|
-
}
|
|
70
115
|
/**
|
|
71
116
|
* Set the child process
|
|
72
117
|
*/
|
|
@@ -76,7 +121,6 @@ class Proxy {
|
|
|
76
121
|
/**
|
|
77
122
|
* Stop the proxy gracefully
|
|
78
123
|
* Sends SIGTERM signal (cross-platform)
|
|
79
|
-
* Node.js automatically converts to appropriate signal on Windows (CTRL_BREAK)
|
|
80
124
|
*/
|
|
81
125
|
async stop() {
|
|
82
126
|
if (!this.process) {
|
|
@@ -105,14 +149,10 @@ class Proxy {
|
|
|
105
149
|
reject(new Error(`Proxy exited with code ${code} signal ${signal}`));
|
|
106
150
|
}
|
|
107
151
|
});
|
|
108
|
-
// Send platform-appropriate signal
|
|
109
|
-
// Unix: SIGTERM (standard kill signal)
|
|
110
|
-
// Windows: Use signal subcommand to send CTRL_BREAK via Windows API
|
|
152
|
+
// Send platform-appropriate signal
|
|
111
153
|
try {
|
|
112
154
|
if (process.platform === 'win32') {
|
|
113
155
|
// On Windows, use the signal subcommand to send CTRL_BREAK
|
|
114
|
-
// The subcommand uses FreeConsole + AttachConsole + GenerateConsoleCtrlEvent
|
|
115
|
-
// to properly deliver console control events to the target process
|
|
116
156
|
const binaryPath = (0, binary_1.getFullBinaryPath)();
|
|
117
157
|
const { spawnSync } = require('child_process');
|
|
118
158
|
const result = spawnSync(binaryPath, ['signal', '--pid', this.process.pid.toString(), '--kind', 'ctrl-break'], { stdio: 'pipe' });
|
|
@@ -146,7 +186,6 @@ class Proxy {
|
|
|
146
186
|
if (!this.process) {
|
|
147
187
|
return false;
|
|
148
188
|
}
|
|
149
|
-
// Check if process is still alive
|
|
150
189
|
try {
|
|
151
190
|
process.kill(this.process.pid, 0);
|
|
152
191
|
return true;
|
|
@@ -175,7 +214,6 @@ class Proxy {
|
|
|
175
214
|
}
|
|
176
215
|
/**
|
|
177
216
|
* Load the inventory for this proxy
|
|
178
|
-
* This is useful after recording is complete
|
|
179
217
|
*/
|
|
180
218
|
async getInventory() {
|
|
181
219
|
const inventoryPath = path.join(this.inventoryDir, 'index.json');
|
|
@@ -189,8 +227,14 @@ exports.Proxy = Proxy;
|
|
|
189
227
|
async function startRecording(options) {
|
|
190
228
|
await (0, binary_1.ensureBinary)();
|
|
191
229
|
const binaryPath = (0, binary_1.getFullBinaryPath)();
|
|
192
|
-
//
|
|
193
|
-
|
|
230
|
+
// Get an available port if not specified or if 0
|
|
231
|
+
let port;
|
|
232
|
+
if (options.port === undefined || options.port === 0) {
|
|
233
|
+
port = await getAvailablePort();
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
port = options.port;
|
|
237
|
+
}
|
|
194
238
|
const deviceType = options.deviceType || 'mobile';
|
|
195
239
|
const inventoryDir = options.inventoryDir || './inventory';
|
|
196
240
|
// Build command
|
|
@@ -199,18 +243,15 @@ async function startRecording(options) {
|
|
|
199
243
|
if (options.entryUrl) {
|
|
200
244
|
args.push(options.entryUrl);
|
|
201
245
|
}
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
args.push('--port', port.toString());
|
|
205
|
-
}
|
|
246
|
+
// Always specify the port explicitly
|
|
247
|
+
args.push('--port', port.toString());
|
|
206
248
|
// Add device type
|
|
207
249
|
args.push('--device', deviceType);
|
|
208
250
|
// Add inventory directory
|
|
209
251
|
args.push('--inventory', inventoryDir);
|
|
210
|
-
//
|
|
211
|
-
// Start the process with piped stdout to capture port info
|
|
252
|
+
// Start the process
|
|
212
253
|
const spawnOptions = {
|
|
213
|
-
stdio: ['ignore', '
|
|
254
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
214
255
|
detached: false,
|
|
215
256
|
};
|
|
216
257
|
if (process.platform === 'win32') {
|
|
@@ -219,46 +260,25 @@ async function startRecording(options) {
|
|
|
219
260
|
const proc = (0, child_process_1.spawn)(binaryPath, args, spawnOptions);
|
|
220
261
|
const proxy = new Proxy('recording', port, inventoryDir, options.entryUrl, deviceType);
|
|
221
262
|
proxy.setProcess(proc);
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
}, 2000);
|
|
231
|
-
proc.stdout?.on('data', (data) => {
|
|
232
|
-
const output = data.toString();
|
|
233
|
-
// Look for "Recording proxy listening on 127.0.0.1:XXXXX" or "Playback proxy listening on 127.0.0.1:XXXXX"
|
|
234
|
-
const match = output.match(/proxy listening on (?:127\.0\.0\.1|0\.0\.0\.0):(\d+)/i);
|
|
235
|
-
if (match && match[1]) {
|
|
236
|
-
const actualPort = parseInt(match[1], 10);
|
|
237
|
-
proxy.updatePort(actualPort);
|
|
238
|
-
if (!resolved) {
|
|
239
|
-
resolved = true;
|
|
240
|
-
clearTimeout(timeout);
|
|
241
|
-
resolve(proxy);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
// Forward output to console
|
|
245
|
-
process.stdout.write(data);
|
|
246
|
-
});
|
|
247
|
-
proc.on('error', (err) => {
|
|
248
|
-
if (!resolved) {
|
|
249
|
-
resolved = true;
|
|
250
|
-
clearTimeout(timeout);
|
|
251
|
-
reject(err);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
proc.on('exit', (code) => {
|
|
255
|
-
if (!resolved && code !== 0) {
|
|
256
|
-
resolved = true;
|
|
257
|
-
clearTimeout(timeout);
|
|
258
|
-
reject(new Error(`Proxy exited with code ${code}`));
|
|
259
|
-
}
|
|
260
|
-
});
|
|
263
|
+
// Handle early exit
|
|
264
|
+
let exited = false;
|
|
265
|
+
proc.on('exit', (code) => {
|
|
266
|
+
exited = true;
|
|
267
|
+
if (code !== 0 && code !== null) {
|
|
268
|
+
console.error(`Proxy process exited early with code ${code}`);
|
|
269
|
+
}
|
|
261
270
|
});
|
|
271
|
+
// Wait for the port to become available
|
|
272
|
+
try {
|
|
273
|
+
await waitForPort(port, 15000);
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
if (exited) {
|
|
277
|
+
throw new Error('Proxy process exited before port became available');
|
|
278
|
+
}
|
|
279
|
+
throw err;
|
|
280
|
+
}
|
|
281
|
+
return proxy;
|
|
262
282
|
}
|
|
263
283
|
/**
|
|
264
284
|
* Start a playback proxy
|
|
@@ -266,25 +286,29 @@ async function startRecording(options) {
|
|
|
266
286
|
async function startPlayback(options) {
|
|
267
287
|
await (0, binary_1.ensureBinary)();
|
|
268
288
|
const binaryPath = (0, binary_1.getFullBinaryPath)();
|
|
269
|
-
// Set defaults
|
|
270
|
-
const port = options.port !== undefined ? options.port : 18080;
|
|
271
289
|
const inventoryDir = options.inventoryDir || './inventory';
|
|
272
290
|
// Verify inventory exists
|
|
273
291
|
const inventoryPath = getInventoryPath(inventoryDir);
|
|
274
292
|
if (!fs.existsSync(inventoryPath)) {
|
|
275
293
|
throw new Error(`Inventory file not found at ${inventoryPath}`);
|
|
276
294
|
}
|
|
295
|
+
// Get an available port if not specified or if 0
|
|
296
|
+
let port;
|
|
297
|
+
if (options.port === undefined || options.port === 0) {
|
|
298
|
+
port = await getAvailablePort();
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
port = options.port;
|
|
302
|
+
}
|
|
277
303
|
// Build command
|
|
278
304
|
const args = ['playback'];
|
|
279
|
-
//
|
|
280
|
-
|
|
281
|
-
args.push('--port', port.toString());
|
|
282
|
-
}
|
|
305
|
+
// Always specify the port explicitly
|
|
306
|
+
args.push('--port', port.toString());
|
|
283
307
|
// Add inventory directory
|
|
284
308
|
args.push('--inventory', inventoryDir);
|
|
285
|
-
// Start the process
|
|
309
|
+
// Start the process
|
|
286
310
|
const spawnOptions = {
|
|
287
|
-
stdio: ['ignore', '
|
|
311
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
288
312
|
detached: false,
|
|
289
313
|
};
|
|
290
314
|
if (process.platform === 'win32') {
|
|
@@ -293,46 +317,25 @@ async function startPlayback(options) {
|
|
|
293
317
|
const proc = (0, child_process_1.spawn)(binaryPath, args, spawnOptions);
|
|
294
318
|
const proxy = new Proxy('playback', port, inventoryDir);
|
|
295
319
|
proxy.setProcess(proc);
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
}, 2000);
|
|
305
|
-
proc.stdout?.on('data', (data) => {
|
|
306
|
-
const output = data.toString();
|
|
307
|
-
// Look for "Playback proxy listening on 127.0.0.1:XXXXX"
|
|
308
|
-
const match = output.match(/proxy listening on (?:127\.0\.0\.1|0\.0\.0\.0):(\d+)/i);
|
|
309
|
-
if (match && match[1]) {
|
|
310
|
-
const actualPort = parseInt(match[1], 10);
|
|
311
|
-
proxy.updatePort(actualPort);
|
|
312
|
-
if (!resolved) {
|
|
313
|
-
resolved = true;
|
|
314
|
-
clearTimeout(timeout);
|
|
315
|
-
resolve(proxy);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
// Forward output to console
|
|
319
|
-
process.stdout.write(data);
|
|
320
|
-
});
|
|
321
|
-
proc.on('error', (err) => {
|
|
322
|
-
if (!resolved) {
|
|
323
|
-
resolved = true;
|
|
324
|
-
clearTimeout(timeout);
|
|
325
|
-
reject(err);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
proc.on('exit', (code) => {
|
|
329
|
-
if (!resolved && code !== 0) {
|
|
330
|
-
resolved = true;
|
|
331
|
-
clearTimeout(timeout);
|
|
332
|
-
reject(new Error(`Proxy exited with code ${code}`));
|
|
333
|
-
}
|
|
334
|
-
});
|
|
320
|
+
// Handle early exit
|
|
321
|
+
let exited = false;
|
|
322
|
+
proc.on('exit', (code) => {
|
|
323
|
+
exited = true;
|
|
324
|
+
if (code !== 0 && code !== null) {
|
|
325
|
+
console.error(`Proxy process exited early with code ${code}`);
|
|
326
|
+
}
|
|
335
327
|
});
|
|
328
|
+
// Wait for the port to become available
|
|
329
|
+
try {
|
|
330
|
+
await waitForPort(port, 15000);
|
|
331
|
+
}
|
|
332
|
+
catch (err) {
|
|
333
|
+
if (exited) {
|
|
334
|
+
throw new Error('Proxy process exited before port became available');
|
|
335
|
+
}
|
|
336
|
+
throw err;
|
|
337
|
+
}
|
|
338
|
+
return proxy;
|
|
336
339
|
}
|
|
337
340
|
/**
|
|
338
341
|
* Load an inventory from a JSON file
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const node_test_1 = require("node:test");
|
|
40
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const os = __importStar(require("os"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const proxy_1 = require("../proxy");
|
|
45
|
+
/**
|
|
46
|
+
* Helper to create a temporary directory
|
|
47
|
+
*/
|
|
48
|
+
function createTempDir(prefix) {
|
|
49
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Helper to sleep for a given number of milliseconds
|
|
53
|
+
*/
|
|
54
|
+
function sleep(ms) {
|
|
55
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
56
|
+
}
|
|
57
|
+
(0, node_test_1.describe)('Signal Shutdown', () => {
|
|
58
|
+
(0, node_test_1.test)('RecordingProxySignalShutdown', async () => {
|
|
59
|
+
const tmpDir = createTempDir('test-recording-shutdown-');
|
|
60
|
+
try {
|
|
61
|
+
// Start recording proxy with auto-assigned port
|
|
62
|
+
const proxy = await (0, proxy_1.startRecording)({
|
|
63
|
+
port: 0,
|
|
64
|
+
inventoryDir: tmpDir,
|
|
65
|
+
});
|
|
66
|
+
// Give it time to fully start
|
|
67
|
+
await sleep(2000);
|
|
68
|
+
// Verify it's running
|
|
69
|
+
node_assert_1.default.strictEqual(proxy.isRunning(), true, 'Proxy should be running');
|
|
70
|
+
console.log(`Recording proxy started on port ${proxy.port}`);
|
|
71
|
+
// Stop using signal-based shutdown (SIGTERM on Unix, CTRL_BREAK on Windows)
|
|
72
|
+
await proxy.stop();
|
|
73
|
+
// Verify it stopped
|
|
74
|
+
await sleep(1000);
|
|
75
|
+
node_assert_1.default.strictEqual(proxy.isRunning(), false, 'Proxy should have stopped');
|
|
76
|
+
console.log('Recording proxy stopped successfully via signal shutdown');
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
// Clean up temp directory
|
|
80
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
(0, node_test_1.test)('PlaybackProxySignalShutdown', async () => {
|
|
84
|
+
const tmpDir = createTempDir('test-playback-shutdown-');
|
|
85
|
+
try {
|
|
86
|
+
// Create a minimal inventory
|
|
87
|
+
const inventoryPath = path.join(tmpDir, 'index.json');
|
|
88
|
+
const inventory = {
|
|
89
|
+
resources: [],
|
|
90
|
+
};
|
|
91
|
+
await (0, proxy_1.saveInventory)(inventoryPath, inventory);
|
|
92
|
+
// Start playback proxy with auto-assigned port
|
|
93
|
+
const proxy = await (0, proxy_1.startPlayback)({
|
|
94
|
+
port: 0,
|
|
95
|
+
inventoryDir: tmpDir,
|
|
96
|
+
});
|
|
97
|
+
// Give it time to fully start
|
|
98
|
+
await sleep(2000);
|
|
99
|
+
// Verify it's running
|
|
100
|
+
node_assert_1.default.strictEqual(proxy.isRunning(), true, 'Proxy should be running');
|
|
101
|
+
console.log(`Playback proxy started on port ${proxy.port}`);
|
|
102
|
+
// Stop using signal-based shutdown (SIGTERM on Unix, CTRL_BREAK on Windows)
|
|
103
|
+
await proxy.stop();
|
|
104
|
+
// Verify it stopped
|
|
105
|
+
await sleep(1000);
|
|
106
|
+
node_assert_1.default.strictEqual(proxy.isRunning(), false, 'Proxy should have stopped');
|
|
107
|
+
console.log('Playback proxy stopped successfully via signal shutdown');
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
// Clean up temp directory
|
|
111
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=shutdown.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown.test.js","sourceRoot":"","sources":["../../src/test/shutdown.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2C;AAC3C,8DAAiC;AACjC,uCAAyB;AACzB,uCAAyB;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,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-http-playback-proxy",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "HTTP traffic recording and playback proxy with precise timing control for PageSpeed optimization and performance testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"files": [
|
|
58
58
|
"dist",
|
|
59
59
|
"bin",
|
|
60
|
-
"README.md"
|
|
60
|
+
"README.md",
|
|
61
|
+
"LICENSE"
|
|
61
62
|
],
|
|
62
63
|
"engines": {
|
|
63
64
|
"node": ">=18.0.0"
|