()
| 39 | } |
| 40 | |
| 41 | function initProxy() { |
| 42 | const proxy = createProxyServer(); |
| 43 | |
| 44 | function randomTarget() { |
| 45 | return [ |
| 46 | "http://localhost:3001", |
| 47 | "http://localhost:3002", |
| 48 | "http://localhost:3003", |
| 49 | ][Math.floor(Math.random() * 3)]; |
| 50 | } |
| 51 | |
| 52 | const httpServer = createServer((req, res) => { |
| 53 | proxy.web(req, res, { target: randomTarget() }); |
| 54 | }); |
| 55 | |
| 56 | httpServer.on("upgrade", function (req, socket, head) { |
| 57 | proxy.ws(req, socket, head, { target: randomTarget() }); |
| 58 | }); |
| 59 | |
| 60 | httpServer.listen(3000); |
| 61 | } |
| 62 | |
| 63 | await Promise.all([initServer(3001), initServer(3002), initServer(3003)]); |
| 64 |
no test coverage detected