Initial setup and test
Set up wgctrl library Simple create device and if it exists list the number of clients
This commit is contained in:
20
main.go
Normal file
20
main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"golang.zx2c4.com/wireguard/wgctrl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client, _ := wgctrl.New()
|
||||
defer client.Close()
|
||||
|
||||
dev, err := client.Device("wg0")
|
||||
if err != nil {
|
||||
log.Fatalf("get device error: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Device %s has %d peers\n", dev.Name, len(dev.Peers))
|
||||
}
|
||||
Reference in New Issue
Block a user