np-maintain / global-tunnel

Global HTTP & HTTPS tunelling agent - hard fork of https://github.com/SalesforceEng/global-tunnel
BSD 3-Clause "New" or "Revised" License
118 stars 20 forks source link

Not proxying http.get #24

Closed roccomuso closed 5 years ago

roccomuso commented 6 years ago

With request works as expected, returning proxied IP address:

const request = require('request')
const globalTunnel = require('global-tunnel-ng')

globalTunnel.initialize({
  host: 'uk902.nordvpn.com',
  port: 80,
  proxyAuth: 'USER:PASS', // authentication
  sockets: 50 // optional pool size
})

const URI = 'https://api.ipify.org'

request.get({url: URI }, (err, res, body) => {
  // Do stuff with response
  if (err) console.error(err)
  else {
    console.log(res)
    console.log(body)
  }
});

Using https doesn't, it returns my original IP:

const https = require('https')
const globalTunnel = require('global-tunnel-ng')

globalTunnel.initialize({
  host: 'uk902.nordvpn.com',
  port: 80,
  proxyAuth: 'USER:PASS', // authentication
  sockets: 50 // optional pool size
})

const URI = 'https://api.ipify.org'

https.get(URI, (res) => {
  let buff = Buffer.alloc(0)
  res.on('data', (chunk) => {
    buff = Buffer.concat([buff, chunk])
  })
  res.on('end', () => {
    console.log(buff.toString())
  })
});

What am I missing?

MarcoScabbiolo commented 6 years ago

Looks like http.get is not being proxied but http.request and request are, I've added end to end tests.

We need to detect why http.get is not being proxied, write the regression tests and then solve the issue.

roccomuso commented 5 years ago

thanks