let's debug the things again

This commit is contained in:
Adrien PONSIN 2025-04-16 12:35:25 +02:00
parent 6a1242813b
commit 6eb7b84495
No known key found for this signature in database
GPG Key ID: 7B4D4A32C05C475E

View File

@ -153,6 +153,7 @@ func (ph *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if ok { if ok {
if err := checkMethodPath(r, mr); err != nil { if err := checkMethodPath(r, mr); err != nil {
handleError(w, err) handleError(w, err)
log.Err(err).Send()
return return
} }
} else { } else {
@ -165,13 +166,15 @@ 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)
// log.Err(err).Send() log.Err(err).Send()
return return
} }
for _, resolvedIP := range resolvedIPs { for _, resolvedIP := range resolvedIPs {
log.Debug().Msgf("resolvedIP: %s -- IP: %s", resolvedIP.String(), ip.String())
if resolvedIP.Equal(ip) { if resolvedIP.Equal(ip) {
if err = checkMethodPath(r, mr); err != nil { if err = checkMethodPath(r, mr); err != nil {
handleError(w, err) handleError(w, err)
log.Err(err).Send()
return return
} }
ph.rp.ServeHTTP(w, r) ph.rp.ServeHTTP(w, r)
@ -448,7 +451,6 @@ func addRequests() cli.Flag {
Value: []string{"*:" + defaultAllowedRequest}, Value: []string{"*:" + defaultAllowedRequest},
Aliases: middleman.PluckAlias(ServeCmd, addRequestsFlagName), Aliases: middleman.PluckAlias(ServeCmd, addRequestsFlagName),
Action: func(ctx context.Context, command *cli.Command, requests []string) error { Action: func(ctx context.Context, command *cli.Command, requests []string) error {
log.Info().Msgf("%d", len(requests))
clear(containerMethodRegex) clear(containerMethodRegex)
for _, request := range requests { for _, request := range requests {
// An applicator is a container name/HTTP method pair e.g., nginx(GET). // An applicator is a container name/HTTP method pair e.g., nginx(GET).