summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-04-11 01:25:39 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2020-05-08 18:52:55 +0200
commitfb479b973f8ae9ee15003b8da0d08e3748fba31e (patch)
treec2bb3eebe0b5e1e1ade06db21e5a0ff3d93dc10c /proto
parentb1c4a1954eb715aa657b0aa357ae9dffe2475b0b (diff)
Wireguard: Implement copy_config
Diffstat (limited to 'proto')
-rw-r--r--proto/wireguard/wireguard.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c
index 35b69c54..bea7e33f 100644
--- a/proto/wireguard/wireguard.c
+++ b/proto/wireguard/wireguard.c
@@ -979,6 +979,30 @@ wg_dump(struct proto *P)
}
}
+static void
+wg_copy_config(struct proto_config *DEST, struct proto_config *SRC)
+{
+ struct wg_config *dest = (struct wg_config *)DEST;
+ struct wg_config *src = (struct wg_config *)SRC;
+
+ dest->ifname = src->ifname;
+ dest->socket_path = src->socket_path;
+ dest->private_key = src->private_key;
+ dest->listen_port = src->listen_port;
+
+ struct peer_config *spc = NULL;
+ WALK_LIST(spc,src->peers)
+ {
+ struct peer_config *dpc = cfg_allocz(sizeof(struct peer_config));
+ dpc->public_key = spc->public_key;
+ dpc->listen_port = spc->listen_port;
+ dpc->endpoint = spc->endpoint;
+ dpc->remote_port = spc->remote_port;
+ dpc->allowedip = spc->allowedip;
+ add_tail(&dest->peers, (node*)spc);
+ }
+}
+
struct peer_config *peer_new(struct wg_config *c)
{
struct peer_config *pc = cfg_allocz(sizeof(struct peer_config));
@@ -1062,6 +1086,7 @@ struct protocol proto_wireguard = {
.start = wg_start,
.shutdown = wg_shutdown,
.dump = wg_dump,
+ .copy_config = wg_copy_config,
/* .multitable = 1,
.preference = DEF_PREF_PIPE,
.cleanup = wg_cleanup,