Enable manhole on pinecone

This commit is contained in:
Neil Alexander 2022-09-13 14:11:57 +01:00
parent b215925d55
commit 18cfdabc19
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 9 additions and 1 deletions

View file

@ -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"]
ENTRYPOINT ["/usr/bin/pinecone", "-listenws=:65433", "-listen=:65432", "-manhole"]

View file

@ -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)