-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
send smtp email through a proxy #27349
Conversation
"modules/proxy" should be improved, instead of introducing a totally new mechanism. |
Looks like it's not finished. |
|
It's finished. the |
according to @wxiaoguang and @silverwind's comments, the strategy is to configure proxies in app.ini prior to the shell environment variable in order to behave clearly. the |
A specific ini option sound much better then relying on Apparently there is already a known bug in golang related to the variable: golang/go#16715 |
That's not true. HTTP CONNECT proxy can also be used for any TCP protocol.
From a system design view, the Gitea should have the consistent proxy behavior.
Although at the moment I won't say "block" for it, but I really don't like this strange (inconsistent) behavior. |
ecd9645
to
d959659
Compare
|
I am pretty sure implementing the HTTP CONNECT proxy support is the right approach, and it's not difficult, like this: https://gist.github.com/jim3ma/3750675f141669ac4702bc9deaf31c6b . HTTP CONNECT proxy is exactly (almost) the same as SOCKS5H proxy. |
modules/proxy/httpsdialer.go is owned to https://gist.github.com/jim3ma/3750675f141669ac4702bc9deaf31c6b updated to reuse [proxy]. and add a property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Gitea's proxy system has many legacy problems.
I vote my approval here and will do some improvements in following PRs.
Still lint failures. |
} | ||
reqURL.Scheme = "" | ||
|
||
req, err := http.NewRequest("CONNECT", reqURL.String(), nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we could use httplib.NewRequest
instead, which also brings the benefit of setting a common user-agent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being late. As I check the httplib.NewRequest
, It aims to wrap a normal HTTP request
and it uses the HTTP proxy environment variable internally :
TLSClientConfig: r.setting.TLSClientConfig,
Proxy: http.ProxyFromEnvironment,
while herein the proxy/httpsdialer.go
just make a CONNECT
to the proxy per se.
…fication.. 1. read configure from [smtp_proxy] at first. 2. if smtp_proxy:enabled is true but smtp_proxy:proxy_url is "", read all_proxy/ALL_PROXY, and NO_PROXY/no_proxy from enviroment variables. 3. if smtp_proxy:enabled is false ( default ), ignore both configration in app.ini and environment variables.
An alternative solution works : https://github.com/ankraft/smtpproxy |
This PR addresses the issue #27348.
The notification mailing will leverage the environment variable,
ALL_PROXY
if it is exported.