From 18cfdabc19bbcff384d9aaa872e25a0b104f985a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 13 Sep 2022 14:11:57 +0100 Subject: [PATCH] Enable manhole on `pinecone` --- Dockerfile | 2 +- cmd/pinecone/main.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5d3d2c7..b91789b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,4 @@ COPY --from=base /build/bin/* /usr/bin/ EXPOSE 65432/tcp EXPOSE 65433/tcp -ENTRYPOINT ["/usr/bin/pinecone", "-listenws=:65433", "-listen=:65432"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/pinecone", "-listenws=:65433", "-listen=:65432", "-manhole"] \ No newline at end of file diff --git a/cmd/pinecone/main.go b/cmd/pinecone/main.go index 5774c97..0e2d0b6 100644 --- a/cmd/pinecone/main.go +++ b/cmd/pinecone/main.go @@ -62,6 +62,7 @@ func main() { listentcp := flag.String("listen", ":0", "address to listen for TCP connections") listenws := flag.String("listenws", ":0", "address to listen for WebSockets connections") connect := flag.String("connect", "", "peer to connect to") + manhole := flag.Bool("manhole", false, "enable the manhole (requires WebSocket listener to be active)") flag.Parse() if connect != nil && *connect != "" { @@ -91,6 +92,13 @@ func main() { } }) + if *manhole { + fmt.Println("Enabling manhole on HTTP listener") + http.DefaultServeMux.HandleFunc("/manhole", func(w http.ResponseWriter, r *http.Request) { + pineconeRouter.ManholeHandler(w, r) + }) + } + listener, err := listener.Listen(context.Background(), "tcp", *listenws) if err != nil { panic(err)