Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add proxy for telegram notify #181

Open
nikit0zzz opened this issue Sep 24, 2018 · 7 comments
Open

add proxy for telegram notify #181

nikit0zzz opened this issue Sep 24, 2018 · 7 comments

Comments

@nikit0zzz
Copy link

it is possible to add a proxy for telegram

@xiaoniu-578fa6bff964d005
Copy link
Contributor

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

@xiaoniu-578fa6bff964d005
Copy link
Contributor

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.

@xiaoniu-578fa6bff964d005
Copy link
Contributor

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

@xiaoniu-578fa6bff964d005
Copy link
Contributor

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.

@dschep
Copy link
Owner

dschep commented Sep 26, 2018

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
Copy link
Owner

dschep commented Sep 26, 2018

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.

@nikit0zzz
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants