Skip to content

Commit

Permalink
construct wgctrl client in setup()
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhited committed May 13, 2020
1 parent c103287 commit 8ea2232
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion setup.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
package wgsd

import (
"fmt"

"github.com/caddyserver/caddy"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"golang.zx2c4.com/wireguard/wgctrl"
)

func init() {
plugin.Register("wgsd", setup)
}

func setup(c *caddy.Controller) error {
client, err := wgctrl.New()
if err != nil {
return fmt.Errorf("wgsd: error constructing wgctrl client: %v",
err)
}

// TODO: parse zone and wireguard device name from config

// Add the Plugin to CoreDNS, so Servers can use it in their plugin chain.
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
return &WGSD{Next: next}
return &WGSD{
Next: next,
client: client,
}
})

return nil
Expand Down

0 comments on commit 8ea2232

Please sign in to comment.