forked from shadowsocks/shadowsocks-dotcloud
-
Notifications
You must be signed in to change notification settings - Fork 468
/
Copy pathtest.js
36 lines (32 loc) · 747 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import child_process from 'child_process';
import local from './local.js';
import server from './server.js';
async function runCurl() {
const curl = child_process.spawn('curl', [
'-v',
'https://example.com',
'-L',
'--socks5',
'127.0.0.1:1080',
]);
curl.on('exit', function (code) {
if (code === 0) {
console.log('Test passed');
process.exit(0);
} else {
console.error('Test failed');
process.exit(code);
}
});
curl.stdout.pipe(process.stdout);
curl.stderr.pipe(process.stderr);
await new Promise((r) => {
curl.on('close', r);
});
}
while (true) {
if (local.listening && server.listening) {
await runCurl();
}
await new Promise((r) => setTimeout(r, 100));
}