| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6b44df2 commit be90817
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,7 @@ function test(keyPath, certPath, check, next) { | |||
| 62 | 62 | const cert = fixtures.readSync(certPath).toString(); | |
| 63 | 63 | ||
| 64 | 64 | const server = spawn(common.opensslCli, ['s_server', | |
| 65 | - '-accept', common.PORT, | ||
| 65 | + '-accept', 0, | ||
| 66 | 66 | '-cert', fixtures.path(certPath), | |
| 67 | 67 | '-key', fixtures.path(keyPath)]); | |
| 68 | 68 | server.stdout.pipe(process.stdout); | |
@@ -78,10 +78,11 @@ function test(keyPath, certPath, check, next) { | |||
| 78 | 78 | console.log(state); | |
| 79 | 79 | switch (state) { | |
| 80 | 80 | case 'WAIT-ACCEPT': | |
| 81 | - if (/ACCEPT/.test(serverStdoutBuffer)) { | ||
| 82 | - // Give s_server half a second to start up. | ||
| 83 | - setTimeout(startClient, 500); | ||
| 81 | + const matches = serverStdoutBuffer.match(/ACCEPT .*?:(\d+)/); | ||
| 82 | + if (matches) { | ||
| 83 | + const port = matches[1]; | ||
| 84 | 84 | state = 'WAIT-HELLO'; | |
| 85 | + startClient(port); | ||
| 85 | 86 | } | |
| 86 | 87 | break; | |
| 87 | 88 | ||
@@ -117,7 +118,7 @@ function test(keyPath, certPath, check, next) { | |||
| 117 | 118 | }); | |
| 118 | 119 | ||
| 119 | 120 | ||
| 120 | - function startClient() { | ||
| 121 | + function startClient(port) { | ||
| 121 | 122 | const s = new net.Stream(); | |
| 122 | 123 | ||
| 123 | 124 | const sslcontext = tls.createSecureContext({ key, cert }); | |
@@ -131,7 +132,7 @@ function test(keyPath, certPath, check, next) { | |||
| 131 | 132 | pair.encrypted.pipe(s); | |
| 132 | 133 | s.pipe(pair.encrypted); | |
| 133 | 134 | ||
| 134 | - s.connect(common.PORT); | ||
| 135 | + s.connect(port); | ||
| 135 | 136 | ||
| 136 | 137 | s.on('connect', function() { | |
| 137 | 138 | console.log('client connected'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments