-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "server, launcher, ts: typescript"
This reverts commit d3f8b8b.
- Loading branch information
Showing
10 changed files
with
158 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const net = require('net') | ||
const dns = require('dns') | ||
const url = require('url') | ||
const rp = require('request-promise') | ||
const Promise = require('bluebird') | ||
|
||
module.exports = { | ||
byPortAndAddress (port, address) { | ||
// https://nodejs.org/api/net.html#net_net_connect_port_host_connectlistener | ||
return new Promise((resolve, reject) => { | ||
const client = net.connect(port, address.address) | ||
|
||
client.on('connect', () => { | ||
client.end() | ||
|
||
resolve(address) | ||
}) | ||
|
||
client.on('error', reject) | ||
}) | ||
}, | ||
|
||
getAddress (port, hostname) { | ||
const fn = this.byPortAndAddress.bind(this, port) | ||
|
||
// promisify at the very last second which enables us to | ||
// modify dns lookup function (via hosts overrides) | ||
const lookupAsync = Promise.promisify(dns.lookup, { context: dns }) | ||
|
||
// this does not go out to the network to figure | ||
// out the addresess. in fact it respects the /etc/hosts file | ||
// https://github.com/nodejs/node/blob/dbdbdd4998e163deecefbb1d34cda84f749844a4/lib/dns.js#L108 | ||
// https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback | ||
return lookupAsync(hostname, { all: true }) | ||
.then((addresses) => { | ||
// convert to an array if string | ||
return [].concat(addresses).map(fn) | ||
}) | ||
.any() | ||
}, | ||
|
||
ensureUrl (urlStr) { | ||
// takes a urlStr and verifies the hostname + port | ||
let { hostname, protocol, port } = url.parse(urlStr) | ||
|
||
if (port == null) { | ||
port = protocol === 'https:' ? '443' : '80' | ||
} | ||
|
||
if (process.env.HTTP_PROXY) { | ||
// cannot make arbitrary connections behind a proxy, attempt HTTP/HTTPS | ||
return rp({ | ||
url: urlStr, | ||
agent: require('./agent'), | ||
proxy: null, | ||
}) | ||
.catch({ name: 'StatusCodeError' }, () => {}) // we just care if it can connect, not if it's a valid resource | ||
} | ||
|
||
return this.getAddress(port, hostname) | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
const os = require('os') | ||
const getWindowsProxy = require('@cypress/get-windows-proxy') | ||
|
||
module.exports = { | ||
_getWindowsProxy () { | ||
return getWindowsProxy() | ||
}, | ||
|
||
_normalizeEnvironmentProxy () { | ||
if (!process.env.HTTPS_PROXY) { | ||
// request library will use HTTP_PROXY as a fallback for HTTPS urls, but | ||
// proxy-from-env will not, so let's just force it to fall back like this | ||
process.env.HTTPS_PROXY = process.env.HTTP_PROXY | ||
} | ||
|
||
if (!process.env.NO_PROXY) { | ||
// don't proxy localhost, to match Chrome's default behavior and user expectation | ||
process.env.NO_PROXY = 'localhost' | ||
} | ||
}, | ||
|
||
loadSystemProxySettings () { | ||
if (process.env.HTTP_PROXY !== undefined) { | ||
this._normalizeEnvironmentProxy() | ||
|
||
return | ||
} | ||
|
||
if (os.platform() === 'win32') { | ||
const windowsProxy = this._getWindowsProxy() | ||
|
||
if (windowsProxy) { | ||
process.env.HTTP_PROXY = process.env.HTTPS_PROXY = windowsProxy.httpProxy | ||
process.env.NO_PROXY = process.env.NO_PROXY || windowsProxy.noProxy | ||
} | ||
|
||
this._normalizeEnvironmentProxy() | ||
|
||
return 'win32' | ||
} | ||
}, | ||
} |
Oops, something went wrong.