OctoPrint-Telegram icon indicating copy to clipboard operation
OctoPrint-Telegram copied to clipboard

Implements a Proxy Integration

Open Bart1909 opened this issue 6 years ago • 13 comments

Now, you can use HTTP or SOCKS5 proxies with this bot. In config.yaml under telegram add the two following lines: http_proxy: http://user:[email protected]:3128 https_proxy: http://user:[email protected]:3128

If you are using SOCKS5 proxy, the lines looks like this: http_proxy: socks5://user:[email protected]:3128 https_proxy: socks5://user:[email protected]:3128

Maybe you have to run the following line to install socks-compability: pip install requests[socks]

Bart1909 avatar Apr 27 '18 16:04 Bart1909

2018-05-17_17-01-28 The provider blocks DNS requests or substitutes. Wrap the DNS in a proxy or Tor.

StrannikZet avatar May 18 '18 05:05 StrannikZet

![2018-05-17_17-01-28] The provider blocks DNS requests or substitutes. Wrap the DNS in a proxy or Tor.

Official docs for python requests @StrannikZet Use socks5h scheme instead of socks5.

Ensure your proxy allows dns resolving:

Simulation of local resolver

curl --socks5 your-proxy-host:port https://api.telegram.org -v -v

Simulation of remote resolver (through your socks5)

curl --socks5-hostname your-proxy-host:port https://api.telegram.org -v -v

filimonic avatar Dec 31 '18 19:12 filimonic

@fabianonline Please take a note on this. Very popular feature in Russia

filimonic avatar Jan 01 '19 12:01 filimonic

![2018-05-17_17-01-28] The provider blocks DNS requests or substitutes. Wrap the DNS in a proxy or Tor.

Official docs for python requests @StrannikZet Use socks5h scheme instead of socks5.

Ensure your proxy allows dns resolving:

Simulation of local resolver

curl --socks5 your-proxy-host:port https://api.telegram.org -v -v

Simulation of remote resolver (through your socks5)

curl --socks5-hostname your-proxy-host:port https://api.telegram.org -v -v

I have corrected. Thank you, it works!

StrannikZet avatar Jan 04 '19 08:01 StrannikZet

It is very useful! Can't wait for merge.

rdeanar avatar Jan 23 '19 10:01 rdeanar

It doesn't work any more. Neither socks5 nor socks5h make possible to connect to the server. I receive "Got an exception while initially trying to connect to telegram (Listener not running: HTTPSConnectionPool(host='api.telegram.org', port=443)". Is any idea?

Spirituss avatar Feb 01 '19 11:02 Spirituss

@Spirituss it works for me. You can try to ping host api.telegram.org from terminal of your octoprint server. If it doesn't work, change primary dns server i.e. to Google dns 8.8.8.8 or 8.8.4.4.

rdeanar avatar Feb 05 '19 07:02 rdeanar

It doesn't work any more. Neither socks5 nor socks5h make possible to connect to the server. I receive "Got an exception while initially trying to connect to telegram (Listener not running: HTTPSConnectionPool(host='api.telegram.org', port=443)". Is any idea?

Works good for me. Probably your socks provider is dead ?

filimonic avatar Mar 09 '19 20:03 filimonic

@Spirituss it works for me. You can try to ping host api.telegram.org from terminal of your octoprint server. If it doesn't work, change primary dns server i.e. to Google dns 8.8.8.8 or 8.8.4.4.

You should not change DNS servers. Use "socks5h" instead of "socks5" - this makes DNS resolutions made by socks server, not by client ( "socks5" resolves names NOT through proxy )

filimonic avatar Mar 09 '19 20:03 filimonic

@Spirituss it works for me. You can try to ping host api.telegram.org from terminal of your octoprint server. If it doesn't work, change primary dns server i.e. to Google dns 8.8.8.8 or 8.8.4.4.

This does not work! Providers intercept requests for addresses 8.8.8.8 and 8.8.4.4 for the operation of blocking services.

hallskelet avatar Aug 13 '19 15:08 hallskelet

@Spirituss it works for me. You can try to ping host api.telegram.org from terminal of your octoprint server. If it doesn't work, change primary dns server i.e. to Google dns 8.8.8.8 or 8.8.4.4.

This does not work! Providers intercept requests for addresses 8.8.8.8 and 8.8.4.4 for the operation of blocking services.

You can take 1.1.1.1 or 1.0.0.1 DNS

Vasiy avatar Sep 27 '19 12:09 Vasiy

please, see this way (nging proxy) Add custom server, not api.telegram.org

https://habr.com/ru/post/424427/

whoim2 avatar Apr 30 '20 22:04 whoim2

Hi,

I will finally try to implement that in the master. as there was a lot of conflict I'll implement it on my fork and ask for someone to test because I don't work with proxies.

giloser avatar Feb 18 '21 09:02 giloser