windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SOCKS proxy support?

RingoAl opened this issue · comments

Hello.
Is there any way to use bot through SOCKS proxy? As I can see, there is only an ability to change API URL.
Thanks.

Точно так. Есть возможность сделать ssh на удаленный сервер?

Доступ по SSH есть. Хотите предложить iptables+redsocks ?

Нет. Прокидываете удаленный api.telegram.org:443 как локальный 8443, в hosts ставите адрес api.telegram.org как 127.0.0.1 и ставите https://api.telegram.org:8443 как url в узле telegram-receiver

Прокидываете удаленный api.telegram.org:443 как локальный 8443
При помощи чего?

ssh -L 8443:api.telegram.org:443 remote для начала

Видимо имелось в виду:
ssh -f -N -L 8443:api.telegram.org:443 user@proxy.domain
После чего уже
echo "127.0.0.1 api.telegram.org" >> /etc/hosts
после чего в ноде API URL https://api.telegram.org:8443
Костыль конечно, но вроде работает. Только для этого надо комп/виртуалку, где api.telegram.org доступен. Ну и к SOCKS это не имеет отношения

) главное работает и даёт время найти другие решения.

Это не для меня, для коллеги. У меня через IPv6 работает без Proxy. Коллегу, видимо, через себя прокину.

А вообще telegram node основан на request, который уважает опцию proxy, но автор узла ее не выставил в настройках узла.
Можно его потребить в этом направлении, лучше готовыми коммитами )

Ну node-red-contrib-telegrambot основан на node-telegram-bot-api, а туда socks тоже ещё полноценно не прикрутили, если следить за этим issue
yagop/node-telegram-bot-api#562

Я про более глубокую зависимость, но таки да. Так что костылик пока необходим

Nice conversation, but if you don‘t mind switch to english so that others can read tjis in future in case they have the same problem. Thanks guys.

@windkh here they try to block ordinary access to https://api.telegram.org and we discuss possible ways to work this around.
One option would be to expose via the proxy option of underlying request options. The default of process.env.http_proxy would be the sane default, I believe.
The current workaround is to specify custom baseUrl (https://api.telegram.org:PORT), use ssh port forwarding, and hack dns for api.telegram.org to resolve to 127.0.0.1.

What about the outcome of this discussion? Should we change something in the bot or close this issue?

It would be great to have proxy options in bot settings.
In current solutions we have to change system setting to access api.telegram.org

hm any idea how this can be achieved?
What system settings do you mean? the one from the operating system or from node-red itself?

@windkh: I came here wondering if node-red-contrib-telegrambot supports proxy settings and upon some googling, found this explanation how to invoke node-telegram-bot-api to connect through a proxy. It would be best if such settings were available, but I'm not deep enough into the javascript and node-red ecosystem yet to just offer you a PR.

The solution described in the discussion above is suboptimal, because it involves creating an SSH tunnel that redirects a local port to api.telegram.org through an off-site SSH server, and giving node-red-contrib-telegrambot a localhost URL with the said local port...

Thanks for the input. I will integrate this if I am able to set up that kind of proxy environment at my home... if not maybe you can help me with testing it?

You can use ssh to set up such a proxy at localhost:1080 if you have an offsite server anywhere, or even another ssh-capable machine on your local network:

ssh <host> -N -D 0.0.0.0:1080

Failing that, I could test this for you, but turnaround time will make this a pain.

Hm that pull request is not released yet. I will contact the owner...

According to the comment (my first post here had a direct link to it) the pull request is unnecessary to get socks proxy working, that was why it was not accepted.

Then I will have a closer look ....

Hi guys I release version 5.2.1 with code that hopefully solves that issue.
I could not fully test this, so please support me in testing this.
Waiting for your feedback.

Appears to be working with no issue for me, thank you!

Thank you for testing. Well, there are different kind of proxys SOCKS5 and SOCKS4. What did you check?

The one that SSH gives you -- specifically, I keep an autossh process with a permanent proxy out to a VPS. According to the ssh manpage, it responds as both SOCKS5 and SOCKS4, so I can't tell you just which particular version of the protocol got used.

Ok thanks

Здравствуйте,а поддержку ipv6 нельзя сюда прикрутить как в десктопной версии телеграма?

I tried to translate it using google:
Hello, and ipv6 support can not be screwed here as in the desktop version of the telegram?

@sepbiy what do you mean ?

IPv6 support is working fine, but in my case it tries to connect by IPv4 by default. I had to add only IPv6 address to /etc/hosts to make it works.

I am using a 6in4 Hurricane Electric Tunnel Broker, but it does not work telegram.

Can you provide details? Polling mode? What does the log output say?

msg : string[52]
"EFATAL: Error: connect ETIMEDOUT 149.154.167.220:443"
18.03.2019, 19:23:00
msg : string[43]
"Timeout connecting to server. Trying again."

Polling Mode?

Poll Interval 300

Hm ... strange

Resolving api.telegram.org (api.telegram.org)... 2001:67c:4e8:f004::9, 149.154.167.220
Connecting to api.telegram.org (api.telegram.org)|2001:67c:4e8:f004::9|:80... failed: Connection refused.

Resolving core.telegram.org (core.telegram.org)... 2001:67c:4e8:1029::439:31, 2001:67c:4e8:1029:1:0:439:131, 149.154.167.99
Connecting to core.telegram.org (core.telegram.org)|2001:67c:4e8:1029::439:31|:80... connected.

So the first url refused but the second succeeded...

"EFATAL: Error: connect ETIMEDOUT 149.154.167.99:443"

commented

So how to enable proxy support for mortal people? =)

And there is also MTP-Proxy especially for Telegram...

@ptath ... what do you mean? Or how can I help you?

commented

@ptath ... what do you mean? Or how can I help you?

In Soviet Russia telegram is blocked 10 months ago. So Node-RED[11700]: error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: connect EHOSTUNREACH 149.154.167.220 is fine. On desktop/mobile we are generally using proxy.

So if nodered machine is directly connected to Russian internet, node-red-contrib-telegrambot cannot reach telegram servers and does not works.

Any idea how to configure it to use proxy in node-red?

First you need a proxy server IP that you can use. Do you have one?

Then you should activate SOCKS5 in the configuration node of telegram. Enter the proxy IP together with your credentials and after deploying it should work.

commented

Oops. I've just realized that I'm using node-red-contrib-chatbot, which uses node-red-contrib-telegrambot =)

There is no such option, I'll take a look on original node-red-contrib-telegrambot, thanks.

No, both projects do not make use of each other. The author of the other one started his work on a very early version of the nodes in this project. At least the author noted that he got inspired by this one. But as I said both projects are independent.

commented

No, both projects do not make use of each other. The author of the other one started his work on a very early version of the nodes in this project. At least the author noted that he got inspired by this one. But as I said both projects are independent.

So I was confused by google searching solution for my problem =) Sorry for bothering!

... your welcome. Hope that it will work for you.

Hi everybody! Thanks for kind help,
I'm in Russia and the module doesn't work, but the telegram app on my phone yes, why? There should be a way to make work also the module so..
I tried to use proxy but I wasn't sucessful, I searched around, for example I've found this site:
https://telegramzy.ru/proxy/
the first proxy has 443 open, but they give here a key, and in the module it asked username and password.
May someone kindly explain a simple way to make it work? Thank you a lot!

Issue is fixed in version 11.2.0