From 9240b12e0ddf8b4816d502580cb9c3cedda1cc44 Mon Sep 17 00:00:00 2001 From: Hector van der Aa Date: Mon, 2 Mar 2026 19:31:47 +0100 Subject: [PATCH] newcfg function call --- main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 80166ba..cd82b10 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,8 @@ type server struct { } func (s *server) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResponse, error) { + key, _ := wgtypes.GeneratePrivateKey() + newcfg(s.wgClient, key.PublicKey()) return &pb.PingResponse{Reply: "Pong: " + req.Message}, nil } @@ -41,17 +43,13 @@ func main() { } -func newcfg(client *wgctrl.Client, pubkey string) { - peerPubKey, err := wgtypes.ParseKey(pubkey) - if err != nil { - log.Fatalf("invalid peer public key: %v", err) - } +func newcfg(client *wgctrl.Client, pubkey wgtypes.Key) { allowedIP1 := net.IPNet{IP: net.ParseIP("10.0.0.3"), Mask: net.CIDRMask(32, 32)} persistentKeepalive := 25 * time.Second peerCfg := wgtypes.PeerConfig{ - PublicKey: peerPubKey, + PublicKey: pubkey, AllowedIPs: []net.IPNet{allowedIP1}, PersistentKeepaliveInterval: &persistentKeepalive, }