ngrok-go
ngrok-go copied to clipboard
How to specify a port to tunnel to
i want achieve this same functionality when i use ngrok via ssh; like so : ngrok http 3000 how can i achieve this using this package.
a little peek from the node js ngrok library; i can achieve this by doing this const url = await ngrok.connect(9090);.
i would appreciate if i can be pointed to in the right direction on how to achieve this.
The ngrok-lite example in this repo shows a way to do it with this library.
In that example, dest in net.Dial("tcp", dest) would be localhost:3000 to achieve the same thing as ngrok http 3000 does.
Since this is a pretty common pattern, we're planning to add built-in support to make it a bit easier, though no promises on exactly when. @jrobsonchase has a draft up over in https://github.com/ngrok/ngrok-go/pull/74 if you want to try it out and see if it works for your use-case though
This functionality was added a while ago with the ListenAndForward call, docs here: https://pkg.go.dev/golang.ngrok.com/ngrok#ListenAndForward
closing as fixed