Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api] pprof: remove loopback validation #1252

Merged
merged 1 commit into from
Jun 13, 2024
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
8 changes: 1 addition & 7 deletions cmd/statshouse-api/statshouse-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"fmt"
"log"
"math"
"net"
"net/http"
_ "net/http/pprof" // pprof HTTP handlers
"os"
Expand Down Expand Up @@ -483,12 +482,7 @@ func run(argv args, cfg *api.Config, vkuthPublicKeys map[string][]byte) error {
go func() { // serve pprof on RPC port
m := http.NewServeMux()
m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
remoteAddr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
if err == nil && remoteAddr.IP.IsLoopback() {
http.DefaultServeMux.ServeHTTP(w, r)
} else {
w.WriteHeader(http.StatusUnauthorized)
}
http.DefaultServeMux.ServeHTTP(w, r)
})
log.Printf("serving Go pprof at %q", argv.listenRPCAddr)
s := http.Server{Handler: m}
Expand Down
Loading