A broker daemon to provision the WireGuard peers over gRPC.
$ wiregarden-server --port $PORT
Note: if you faced like operation not permitted
error, please run the server by the legit user.
See the example: examples/wiregarden-client
The following code is a simple example to retrieve peers of wg0
device.
package main
import (
"context"
"fmt"
"log"
"github.com/moznion/wiregarden/grpc/messages"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
conn, err := grpc.Dial("127.0.0.1:54321", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer func() {
_ = conn.Close()
}()
peersClient := messages.NewPeersClient(conn)
resp, err := peersClient.GetPeers(context.Background(), &messages.GetPeersRequest{
DeviceName: "wg0",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", resp.Peers)
}
Currently, it supports the following features:
- GetDevices
- GetPeers
- RegisterPeers
- DeletePeers
It provides "hook" mechanism by the following interfaces:
- handlers.PeersRegistrationHook for
RegisterPeers
- handlers.PeersDeletionHook for
DeletePeers
If you'd like to do the hook(s) on any operations, please pass the implementation(s) of the interface to handlers.Peers struct.
Note: currently it doesn't provide a way to register the hooks by the default wiregarden-server
command. If you'd like to run the server with the hooks, please make your own server launcher based on the cmd/wiregarden-server/main.go.
And, RegisterPeersRequest.HooksPayload []byte
and DeletePeersRequest.HooksPayload []byte
are the extension properties for each hook.
Internally, this application / library uses rs/zerolog as a logger. You can configure the logger according to the manner of the zerolog. Please refer to the document of that.
It provides the wiregarden gRPC library for Java. Please refer to this page.
- Docker
$ make build GOOS=linux GOARCH=amd64
Please change the $GOOS
and GOARCH
to your desired ones.
$ make container4protogen
$ make proto
If you'd like to run the E2E tests, please set the environment value E2E_TEST
with the non-empty value.
$ make e2e-docker-container
$ make e2e-docker-push DOCKER_USER=${GITHUB_USERNAME} DOCKER_PSWD_FILE=/path/to/your/github/token/file
moznion (moznion@mail.moznion.net)