Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions proxyfilters/connectports.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package proxyfilters

import (
"fmt"
"net"
"net/http"
"strconv"
Expand All @@ -27,14 +28,14 @@ func RestrictConnectPorts(allowedPorts []int) filters.Filter {

port, err := strconv.Atoi(portString)
if err != nil {
return fail(cs, req, http.StatusBadRequest, "Invalid port")
return fail(cs, req, http.StatusBadRequest, fmt.Sprintf("Invalid port for %v: %v", req.Host, portString))
}

for _, p := range allowedPorts {
if port == p {
return next(cs, req)
}
}
return fail(cs, req, http.StatusForbidden, "Port not allowed")
return fail(cs, req, http.StatusForbidden, fmt.Sprintf("Port not allowed for %v: %d", req.Host, port))
})
}