filter requests

This commit is contained in:
Vladislav Yarmak 2020-05-24 16:11:50 +03:00
parent 893c0efcf2
commit a8a8bef4db
1 changed files with 5 additions and 0 deletions

View File

@ -87,6 +87,11 @@ func (s *ProxyHandler) HandleRequest(wr http.ResponseWriter, req *http.Request)
func (s *ProxyHandler) ServeHTTP(wr http.ResponseWriter, req *http.Request) { func (s *ProxyHandler) ServeHTTP(wr http.ResponseWriter, req *http.Request) {
s.logger.Info("Request: %v %v %v %v", req.RemoteAddr, req.Proto, req.Method, req.URL) s.logger.Info("Request: %v %v %v %v", req.RemoteAddr, req.Proto, req.Method, req.URL)
if ((req.URL.Host == "" || req.URL.Scheme == "") && req.ProtoMajor < 2) ||
(req.Host == "" && req.ProtoMajor == 2) {
http.Error(wr, "Bad Request", http.StatusBadRequest)
return
}
if !s.auth.Validate(wr, req) { if !s.auth.Validate(wr, req) {
return return
} }