Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
Created August 20, 2018 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk-pmb/df15de493551a3512bbd0812454b362b to your computer and use it in GitHub Desktop.
Save mk-pmb/df15de493551a3512bbd0812454b362b to your computer and use it in GitHub Desktop.
npm:tunnel@0.0.5: .httpsOverHttp uses port 80 as default for CONNECT
import 'p-fatal'
import proxyTunnels from 'tunnel'
import got from 'got'
const tunnelCfg = {
proxy: {
host: 'localhost',
port: 7777,
proxyAuth: 'guest:yolo',
},
}
async function main() {
const reply = await got('https://www.example.net/', {
agent: {
https: proxyTunnels.httpsOverHttp(tunnelCfg),
},
})
console.log(Object.keys(reply).sort(), reply.body.slice(0, 128))
}
main()
$ nodever tunnel
require('tunnel/package.json').version = 0.0.5
Node.js v8.11.4, npm v5.6.0, Ubuntu 14.04.5 LTS trusty,
kernel: 3.13.0-154-generic, machine/CPU/platform: i686 i686 i686
> 2018/08/20 20:23:42.823711 length=125 from=0 to=124
CONNECT www.example.net:80 HTTP/1.1\r
Proxy-Authorization: Basic Z3Vlc3Q6eW9sbw==\r
Host: localhost:7777\r
Connection: close\r
\r
< 2018/08/20 20:23:43.159795 length=68 from=0 to=67
HTTP/1.1 200 Connection established\r
Proxy-Agent: Privoxy/3.0.21\r
\r
> 2018/08/20 20:23:43.181706 length=244 from=125 to=368
...........O[.rdW.".. ...5.,..
.[\t.. o.\t,....n./.+.0.,...'.g.(.k.$...
.........j.i.h.9.8.7.6.2...*.&.......=.5.#...\t.......@.?.>.3.2.1.0.1.-.).%.......<./.....T.........www.example.net.\v.......
.......#...\r. ................................3t..
< 2018/08/20 20:23:43.537526 length=516 from=68 to=583
HTTP/1.0 501 Not Implemented\r
Content-Type: text/html\r
Content-Length: 357\r
Connection: close\r
Date: Mon, 20 Aug 2018 18:23:43 GMT\r
Server: ECSF (dca/249C)\r
\r
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\t<head>
\t\t<title>501 - Not Implemented</title>
\t</head>
\t<body>
\t\t<h1>501 - Not Implemented</h1>
\t</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment