+}
+
+static int
+wg_user_peer_update(struct network *net, struct network_peer *peer, enum wg_update_cmd cmd)
+{
+ struct network_host *host;
+ struct wg_req req;
+ char key[WG_KEY_LEN_HEX];
+
+ if (wg_req_init(&req, net, true))
+ return -1;
+
+ key_to_hex(key, peer->key);
+ wg_req_set(&req, "public_key", key);
+
+ if (cmd == WG_PEER_DELETE) {
+ wg_req_set(&req, "remove", "true");
+ goto out;
+ }
+
+ wg_req_set(&req, "replace_allowed_ips", "true");
+ wg_user_peer_req_add_allowed_ip(&req, peer);
+ for_each_routed_host(host, net, peer)
+ wg_user_peer_req_add_allowed_ip(&req, &host->peer);