summaryrefslogtreecommitdiff
path: root/proto/wireguard
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-26 00:55:09 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-04-02 00:27:38 +0200
commit3bdc9a915ac08f76b8453c3bc2c67398f8f3c9ff (patch)
treee9635faea44256f77f0647296bcfb8df44e3d833 /proto/wireguard
parent91b42ac1d49032d03a43e99e2ae80e9301dfdc45 (diff)
Wireguard: Add peer config settings
Diffstat (limited to 'proto/wireguard')
-rw-r--r--proto/wireguard/config.Y37
-rw-r--r--proto/wireguard/wireguard.h7
2 files changed, 43 insertions, 1 deletions
diff --git a/proto/wireguard/config.Y b/proto/wireguard/config.Y
index 2eee7e72..9a414085 100644
--- a/proto/wireguard/config.Y
+++ b/proto/wireguard/config.Y
@@ -16,7 +16,7 @@ CF_DEFINES
CF_DECLS
-CF_KEYWORDS(WIREGUARD)
+CF_KEYWORDS(WIREGUARD, PUBKEY, ENDPOINT, ALLOWED_IPS)
CF_GRAMMAR
@@ -32,6 +32,41 @@ wireguard_proto:
| wireguard_proto wg_proto_channel ';'
| wireguard_proto proto_item ';'
| wireguard_proto INTERFACE TEXT ';' { WG_CFG->ifname = $3; }
+ | wireguard_proto wg_peer ';'
+ ;
+
+wg_peer: wg_peer_start wg_peer_opt_list wg_peer_end;
+
+wg_peer_start: PEER
+
+wg_peer_end:
+ ;
+
+wg_peer_item:
+ PUBKEY pubkey
+ | ENDPOINT endpoint
+ | PORT port
+ | ALLOWED_IPS allowed_ips
+ ;
+
+wg_peer_opts:
+ /* empty */
+ | wg_peer_opts wg_peer_item ';'
+ ;
+
+wg_peer_opt_list:
+ /* empty */
+ | '{' wg_peer_opts '}'
+ ;
+
+pubkey: text { WG_CFG->peer.pubkey = $1; }
+
+endpoint: ipa { WG_CFG->peer.endpoint = $1; }
+
+port: expr { WG_CFG->peer.remote_port = $1; }
+
+allowed_ips:
+ net_or_ipa { WG_CFG->peer.allowed_ips = $1; }
;
wg_proto_channel: wg_channel_start channel_opt_list wg_channel_end;
diff --git a/proto/wireguard/wireguard.h b/proto/wireguard/wireguard.h
index 3217df32..1292b1c0 100644
--- a/proto/wireguard/wireguard.h
+++ b/proto/wireguard/wireguard.h
@@ -6,6 +6,13 @@
struct wg_config {
struct proto_config c;
const char *ifname;
+
+ struct peer {
+ const char *pubkey;
+ ip_addr endpoint;
+ u16 remote_port;
+ struct net_addr allowed_ips;
+ } peer;
};
struct wg_proto {