ntfy icon indicating copy to clipboard operation
ntfy copied to clipboard

add proxy for telegram notify

Open nikit0zzz opened this issue 6 years ago • 7 comments

it is possible to add a proxy for telegram

nikit0zzz avatar Sep 24 '18 13:09 nikit0zzz

Agree! This is a useful for some people in china.

Using ENV doesn't seem to work. For example, http_proxy=http://127.0.0.1:7777 ntfy -b telegram send "ntfy test" would produce

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f8d2bd8ba90>: Failed to establish a new connection: [Errno 101
] Network is unreachable',)'

While in the same time http_proxy=http://127.0.0.1:7777 http www.google.com is fine.

I got it. https_proxy=http://127.0.0.1:7777 works. Within python we can use os.environ["https_proxy"] = "http://127.0.0.1:7777"

ref https://pypi.org/project/telegram-send/#how-to-use-a-proxy

Are we able to configure environment variable or proxy in ntfy.yml? If so, it would be convenient to assign the ENV without polluting the whole environment. For example, I want to use shell-integration but I can't have automatically started ntfy using proxy I assigned without assigning global ENV or monkey patching ~/.local/share/ntfy/auto-ntfy-done.sh.

Glad you got it working @xiaoniu-578fa6bff964d005! I don't have any plans for supporting setting env vars in the ntfy config, I would suggest adding an alias to your shell rc file. ie, in .bashrc:

alias ntfy='env https_proxy=http://127.0.0.1:7777 ntfy'

dschep avatar Sep 26 '18 12:09 dschep

If that isn't good enough, I'd be happy to consider a well implemented pull request for the benefit of users in countries with censored internet connections. I would prefer a proxy option for the telegram backend and then ntfy would set the env var before calling the telegram dependency.

dschep avatar Sep 26 '18 13:09 dschep

as an option to install torify and replace in zshrc (ntfy shell-integration) with (torify ntfy shell-integration)

nikit0zzz avatar Dec 25 '18 14:12 nikit0zzz