bug fixed?
This commit is contained in:
parent
f84ad18dfd
commit
7011d71c03
@ -151,9 +151,7 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Debug().Str("remote_addr", r.RemoteAddr).Str("http_method", r.Method).Str("path", r.URL.Path).Msg("incoming request")
|
log.Debug().Str("remote_addr", r.RemoteAddr).Str("http_method", r.Method).Str("path", r.URL.Path).Msg("incoming request")
|
||||||
mr, ok := containerMethodRegex["*"]
|
mr, ok := containerMethodRegex["*"]
|
||||||
if ok {
|
if ok {
|
||||||
fmt.Println("here 1")
|
|
||||||
if err := checkMethodPath(w, r, mr); err != nil {
|
if err := checkMethodPath(w, r, mr); err != nil {
|
||||||
fmt.Println("failed here 1")
|
|
||||||
log.Err(err).Send()
|
log.Err(err).Send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -167,29 +165,21 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
resolvedIPs, err := net.LookupIP(containerName)
|
resolvedIPs, err := net.LookupIP(containerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
|
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
|
||||||
fmt.Println("failed here 2")
|
|
||||||
log.Err(err).Send()
|
log.Err(err).Send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("count of resolved IPs: %d\n", len(resolvedIPs))
|
|
||||||
for _, resolvedIP := range resolvedIPs {
|
for _, resolvedIP := range resolvedIPs {
|
||||||
fmt.Printf("resolvedIP: %s -- IP: %s", resolvedIP.String(), ip.String())
|
|
||||||
if resolvedIP.Equal(ip) {
|
if resolvedIP.Equal(ip) {
|
||||||
// fmt.Printf("%s == %s\n", resolvedIP.String(), ip.String())
|
|
||||||
if err = checkMethodPath(w, r, mr); err != nil {
|
if err = checkMethodPath(w, r, mr); err != nil {
|
||||||
fmt.Println("failed here 3")
|
|
||||||
log.Err(err).Send()
|
log.Err(err).Send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("here 2")
|
ph.rp.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
fmt.Println("here 3")
|
|
||||||
}
|
}
|
||||||
fmt.Println("here 4")
|
|
||||||
}
|
}
|
||||||
fmt.Println("here 5")
|
|
||||||
}
|
}
|
||||||
ph.rp.ServeHTTP(w, r)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkMethodPath executes the regular expression on the path of the HTTP request if and only if
|
// checkMethodPath executes the regular expression on the path of the HTTP request if and only if
|
||||||
@ -197,11 +187,9 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
func checkMethodPath(w http.ResponseWriter, r *http.Request, mr methodRegex) error {
|
func checkMethodPath(w http.ResponseWriter, r *http.Request, mr methodRegex) error {
|
||||||
req, ok := mr[r.Method]
|
req, ok := mr[r.Method]
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Printf("%s is not a registered HTTP method\n", r.Method)
|
|
||||||
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
|
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
|
||||||
return ErrHTTPMethodNotAllowed{httpMethod: r.Method}
|
return ErrHTTPMethodNotAllowed{httpMethod: r.Method}
|
||||||
}
|
}
|
||||||
log.Debug().Msgf("%s is a registered HTTP method", r.Method)
|
|
||||||
if !req.MatchString(r.URL.Path) {
|
if !req.MatchString(r.URL.Path) {
|
||||||
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
|
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
|
||||||
return ErrNoMatch{
|
return ErrNoMatch{
|
||||||
@ -209,7 +197,6 @@ func checkMethodPath(w http.ResponseWriter, r *http.Request, mr methodRegex) err
|
|||||||
httpMethod: r.Method,
|
httpMethod: r.Method,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Debug().Msgf("%s matches %s", r.URL.Path, req.String())
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user