Merge pull request #1228 from apernet/wip-masq-proxy-url-scheme

fix: check the URL scheme of `masquerade.proxy.url` in server config
This commit is contained in:
Toby 2024-10-19 09:49:32 -07:00 committed by GitHub
commit 4567713ed8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -804,6 +804,9 @@ func (c *serverConfig) fillMasqHandler(hyConfig *server.Config) error {
if err != nil {
return configError{Field: "masquerade.proxy.url", Err: err}
}
if u.Scheme != "http" && u.Scheme != "https" {
return configError{Field: "masquerade.proxy.url", Err: fmt.Errorf("unsupported protocol scheme \"%s\"", u.Scheme)}
}
handler = &httputil.ReverseProxy{
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(u)