rafaelrinaldi / hn-cli

:newspaper: CLI to browse Hacker News
MIT License
460 stars 19 forks source link

Support proxies #4

Closed imjacobclark closed 6 years ago

imjacobclark commented 8 years ago

When running over SOCKS proxies on my corporate network, I received Request timeout ☹ Might want to try again?.

You should support the standard proxy environmental variables:

http_proxy
https_proxy

I believe using got you can pass tunnel in to go through proxies

const got = require('got');
const tunnel = require('tunnel');

got(url, {
    agent: tunnel.httpOverHttp({
        proxy: {
            host: 'localhost'
        }
    })
});
rafaelrinaldi commented 8 years ago

@imjacobclark As mentioned on our Twitter conversation, I've pushed a WIP of this to the feat/support-proxies branch.

Can you help me testing? To do that:

# Clone this repository
$ git clone git@github.com:rafaelrinaldi/hn-cli.git
# Go to the feature branch
$ cd hn-cli && git checkout feat/support-proxies
# Link the binary to your /usr/local
$ npm link

Thanks!

imjacobclark commented 8 years ago

This still fails for me through my corporate network over SOCKS proxy sadly.

rafaelrinaldi commented 8 years ago

Can you give me more details? Also, I'm wondering the best way to simulate your env so I can work on a fix.

imjacobclark commented 8 years ago

It simply hangs whilst trying to load stories, if you're on OSX, you can simulate a SOCKS proxy via an SSH connection: https://www.mikeash.com/ssh_socks.html

rafaelrinaldi commented 8 years ago

Alright, I will see what I can do. Feel free to submit a PR too :+1:

erickbelfy commented 8 years ago

Hey guys, i would like to take a look on it. Is it working or need more eyes to solve the problem?

rafaelrinaldi commented 8 years ago

@erickbelfy Thanks for jumping in. Feel free to start working on the feat/support-proxies branch. I haven't had the time to come back to this since my last comment anyway so your help will come in very handy!

rafaelrinaldi commented 8 years ago

@erickbelfy Just as an FYI I just published a new release with the --latest feature and also added contribution guidelines. Please, have a look at it when you can :+1:

erickbelfy commented 8 years ago

Sounds good @rafaelrinaldi i will take look as soon as possible, thanks!

erickbelfy commented 8 years ago

Hi @imjacobclark i've installed a SOCKS proxy locally and it works with my recent push. Can you help me testing? you have to update the application following the steps bellow:

# Clone this repository
$ git clone git@github.com:rafaelrinaldi/hn-cli.git
# Go to the feature branch
$ cd hn-cli && git checkout feat/support-proxies
# Link the binary to your /usr/local
$ npm link

Let's see what happen now. Thanks!

shockwavemoto commented 7 years ago

I believe using got you can pass tunnel in to go through proxies ` const got = require('got'); const tunnel = require('tunnel');

got(url, { agent: tunnel.httpOverHttp({ proxy: { host: 'localhost' } }) });` i've installed a SOCKS proxy locally and it works with my recent push. It simply hangs whilst trying to load stories, if you're on OSX, you can simulate a SOCKS proxy via an SSH connection: https://www.mikeash.com/ssh_socks.html

rafaelrinaldi commented 6 years ago

Closing this since we haven’t heard back from the original reporter and also were unable to reproduce.

PRs are welcome.