Hi there,
I just started looking into zrok as ngrok was so limited and I’m loving the functionality. However I have just one question:
On my development machine I have zrok enabled and connected to my account.
On a remote machine (docker container) I automatically enable zrok and have it start (private) sharing a rest api endpoint.
I’m looking for a way to (programmatically via the cli) get a list of other open environments on my zrok account which would include the one running from the docker container on the development machine. This way I can get the share token and open a share programmatically from the dev machine.
After looking at all the commands avaliable I found only this one:
./zrok admin list frontends
but it returns the following error:
goroutine 1 [running]:
main.(*adminListFrontendsCommand).run(0x0?, 0x0?, {0x0?, 0x0?, 0x0?})
/Users/runner/work/zrok/zrok/cmd/zrok/adminListFrontends.go:47 +0x5d3
github.com/spf13/cobra.(*Command).execute(0xc000178300, {0x102ebbbc8, 0x0, 0x0})
/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x102e70140)
/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
main.main()
/Users/runner/work/zrok/zrok/cmd/zrok/main.go:98 +0x25
I’m running the non-self hosted version of zrok.
Can’t find anything in the docs about how to do this, although maybe I’ve overlooked something.
Thanks,
T
Hey T…
I’m the lead developer building zrok
. There’s not currently a way to do this from the CLI. I’ll get it on the backlog and get something pulled together. Can’t promise exactly when, but I’ll try and get it it knocked out sometime relatively soon.
In the meantime, if you were so motivated, you could hit the API directly and query these details. There are already API endpoints to handle all of this (the web console uses them).
Setting up API auth is pretty straightforward… it’s just the enable token from your account. If you wanted to pursue that, and need any clarification, let me know.
Q
The API endpoint you’d want to use is /api/v1/overview
… it returns:
{
"accountLimited": true,
"environments": [
{
"environment": {
"description": "string",
"host": "string",
"address": "string",
"zId": "string",
"activity": [
{
"rx": 0,
"tx": 0
}
],
"limited": true,
"createdAt": 0,
"updatedAt": 0
},
"frontends": [
{
"id": 0,
"shrToken": "string",
"zId": "string",
"createdAt": 0,
"updatedAt": 0
}
],
"shares": [
{
"token": "string",
"zId": "string",
"shareMode": "string",
"backendMode": "string",
"frontendSelection": "string",
"frontendEndpoint": "string",
"backendProxyEndpoint": "string",
"reserved": true,
"activity": [
{
"rx": 0,
"tx": 0
}
],
"limited": true,
"createdAt": 0,
"updatedAt": 0
}
]
}
]
}
There is an OpenAPI spec in specs/zrok.yml
, if that’s helpful.
Actually… would you be happy with raw JSON output listed above? If so, I could probably add a zrok overview
command, which would spit those details out in about 10 minutes.
Would that solve your problem?
Hi Michael,
I’m happy just making a request to the api using the details you provided.
Thanks so much,
T
That works. I’m adding zrok overview
also. Will be released with v0.4.3
. I bet there’ll be other people who need that who don’t want to hit the API themselves.
Coming in v0.4.3
:
$ zrok overview | jq
{
"environments": [
{
"environment": {
"address": "127.0.0.1",
"createdAt": 1689356838275,
"description": "michael@ziti-lx",
"host": "michael; ziti-lx; linux; ubuntu; debian; 22.04; 5.19.0-46-generic; x86_64",
"updatedAt": 1689356838275,
"zId": "d4B6CfRY.8"
},
"shares": [
{
"backendMode": "proxy",
"backendProxyEndpoint": "http://localhost:8080",
"createdAt": 1689780534706,
"frontendEndpoint": "http://w5uufq60mfxk.zrok.quigley.com:8080",
"frontendSelection": "public",
"shareMode": "public",
"token": "w5uufq60mfxk",
"updatedAt": 1689780534706,
"zId": "4aysJ01hg0bnG81js7Zq5K"
}
]
}
]
}