botgram / shell-bot

:robot: Telegram bot that executes commands and sends the live output
GNU General Public License v3.0
797 stars 488 forks source link

Added https and socks5 proxy from env #7

Closed avissian closed 5 years ago

mildsunrise commented 5 years ago

Hi! I've added SOCKS + HTTPS proxy support on master, can you test to see if it works?

avissian commented 5 years ago

Not working with username and password. Server without authorization need to search, I do not.

$ https_proxy=socks5://user:password@server npm start

> shell-bot@0.0.1 start /home/avissian/tmp/shell-bot
> node server.js

Couldn't load the configuration file, starting the wizard.

First, enter your bot API token: ---------:-----------------------------------
/home/avissian/tmp/shell-bot/node_modules/socks/build/common/helpers.js:27
        throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options);
        ^

Error: Invalid SOCKS proxy details were provided.
    at Object.validateSocksClientOptions (/home/avissian/tmp/shell-bot/node_modules/socks/build/common/helpers.js:27:15)
    at Function.createConnection (/home/avissian/tmp/shell-bot/node_modules/socks/build/client/socksclient.js:38:19)
    at GetAddrInfoReqWrap.onlookup [as callback] (/home/avissian/tmp/shell-bot/node_modules/socks-proxy-agent/index.js:118:17)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:62:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shell-bot@0.0.1 start: `node server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the shell-bot@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/avissian/.npm/_logs/2019-02-23T05_52_05_852Z-debug.log
mildsunrise commented 5 years ago

Okay, it seems you have to use an IP address instead of a hostname, socks module doesn't support it. https_proxy=socks5://user:password@127.0.0.1 for instance, should work.

avissian commented 5 years ago

With IP:

First, enter your bot API token: *
Invalid token was entered, please try again.
NetworkError: getMe failed: Error: Received invalid Socks5 initial handshake (no accepted authentication type)

I will try to find the cause later.

avissian commented 5 years ago

Deleted text

Okay, it's working. I have some errors with socks5 server config (but telegram working with these problems, it's strange).

I have 2 socks users with separate server config, USER1 has limitations and working only with telegram and my proxy implementation (why?), USER2 working with anything (your proxy implementation, browser, etc). Before that, I tested it with USER1

mildsunrise commented 5 years ago

It'd be interesting to investigate. If you can capture traffic (i.e. with Wireshark) of this proxy authenticating with both SOCKS5 users, and also Telegram authenticating with both users, I'll look into it.