mirror of
https://git.phreedom.club/localhost_frssoft/compy.git
synced 2024-12-02 11:26:39 +00:00
Check HTTP auth before allowing CONNECT
This commit is contained in:
parent
defbc287f1
commit
703cb4adaf
|
@ -82,10 +82,6 @@ func (p *Proxy) checkHttpBasicAuth(auth string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
|
func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
|
||||||
if r.Method == "CONNECT" {
|
|
||||||
return p.handleConnect(w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: only HTTPS?
|
// TODO: only HTTPS?
|
||||||
if p.user != "" {
|
if p.user != "" {
|
||||||
if !p.checkHttpBasicAuth(r.Header.Get("Proxy-Authorization")) {
|
if !p.checkHttpBasicAuth(r.Header.Get("Proxy-Authorization")) {
|
||||||
|
@ -95,6 +91,10 @@ func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.Method == "CONNECT" {
|
||||||
|
return p.handleConnect(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := forward(r)
|
resp, err := forward(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
|
Loading…
Reference in a new issue