forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix proxying HTTPS requests to IP addresses (cypress-io#4947)
* use own server-destroy implementation that supports secureConnect events * stand up HTTPS server for requests over ssl to IPs * don't need to resolve with * fix tests * stand up a server on 127.0.0.1 for test * tighten up / cleanup code, consolidate + refactor - lazily fs.outputfile’s - move sslIpServers to be global - add remove all CA utility * Improve proxy_spec test * Don't crash on server error events * feedback * derp Co-authored-by: Brian Mann <brian.mann86@gmail.com>
- Loading branch information
1 parent
a8c0e61
commit 7e2f5df
Showing
13 changed files
with
186 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import net from 'net' | ||
|
||
/** | ||
* `allowDestroy` adds a `destroy` method to a `net.Server`. `destroy(cb)` | ||
* will kill all open connections and call `cb` when the server is closed. | ||
* | ||
* Note: `server-destroy` NPM package cannot be used - it does not track | ||
* `secureConnection` events. | ||
*/ | ||
export function allowDestroy (server: net.Server) { | ||
let connections: net.Socket[] = [] | ||
|
||
function trackConn (conn) { | ||
connections.push(conn) | ||
|
||
conn.on('close', () => { | ||
connections = connections.filter((connection) => connection !== conn) | ||
}) | ||
} | ||
|
||
server.on('connection', trackConn) | ||
server.on('secureConnection', trackConn) | ||
|
||
// @ts-ignore Property 'destroy' does not exist on type 'Server'. | ||
server.destroy = function (cb) { | ||
server.close(cb) | ||
connections.map((connection) => connection.destroy()) | ||
} | ||
|
||
return server | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import agent from './agent' | ||
import * as connect from './connect' | ||
import { allowDestroy } from './allow-destroy' | ||
|
||
export { agent } | ||
|
||
export { connect } | ||
export { | ||
agent, | ||
allowDestroy, | ||
connect, | ||
} |
Oops, something went wrong.