https://github.com/erikh/go-ztone
ZeroTier One local client library for Golang
https://github.com/erikh/go-ztone
Last synced: 8 months ago
JSON representation
ZeroTier One local client library for Golang
- Host: GitHub
- URL: https://github.com/erikh/go-ztone
- Owner: erikh
- License: bsd-3-clause
- Created: 2021-03-21T11:09:29.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-23T11:24:36.000Z (about 5 years ago)
- Last Synced: 2025-02-08T10:42:38.932Z (over 1 year ago)
- Language: Go
- Size: 9.77 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-ztone: a client to the ZeroTier One local configuration socket
`go-ztone` is for using against your local [ZeroTier One](https://www.zerotier.com) instance. You must use the "secret authtoken" described in [this document](https://github.com/zerotier/zerotierone#running). For the examples specifically, the convention is to use `ZEROTIER_ONE_TOKEN` on the commandline to assign it into the environment.
```go
package main
import (
"fmt"
"os"
one "github.com/erikh/go-ztone"
)
func main() {
c := one.NewClient(os.Getenv("ZEROTIER_ONE_TOKEN"))
networks, err := c.Networks()
if err != nil {
panic(err)
}
peers, err := c.Peers()
if err != nil {
panic(err)
}
fmt.Println("Networks w/ MAC:")
for _, network := range networks {
fmt.Println(network.ID, network.MAC)
}
fmt.Println("Peers w/ Latency:")
for _, peer := range peers {
fmt.Println(peer.Address, peer.Latency)
}
}
```
## Functionality
`ztone` has a few basic functions, most of them [listed here](https://github.com/zerotier/ZeroTierOne/blob/master/service/README.md#network-virtualization-service-api), as well as on the [GoDoc](https://pkg.go.dev/github.com/erikh/go-ztone).
## Example Code
You can see examples in the `examples/` directory. There are two:
- `list-things`: lists a few different properties and takes no arguments.
- `query-things`: takes a network ID and returns a few properties about it.
# Author
Erik Hollensbe
# License
BSD 3-Clause