diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-09-29 22:26:33 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-09-13 18:05:34 +0200 |
commit | 590ba537906c03b4a07604aad243a330e3eb6f91 (patch) | |
tree | a561cf9582c95d0e6e93a69ba36f0ebfbde717c7 | |
parent | cdf197d153921f098bc8f026d629f9a72f688f40 (diff) |
TunnelEncaps: Add wireguard peer key to tunnel encap format
-rw-r--r-- | lib/tunnel_encaps.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/tunnel_encaps.c b/lib/tunnel_encaps.c index aa3e6b29..590cf958 100644 --- a/lib/tunnel_encaps.c +++ b/lib/tunnel_encaps.c @@ -269,13 +269,21 @@ int format_tunnel_encap(const eattr *a, byte *buf, uint size) return pos - buf; ADVANCE(pos, size, l); - for (uint i = 0; i < encap.encap_len; i++) { - if (size < 4) { - return pos - buf; - } + if (encap.encap_len == sizeof(wg_key)) { + wg_key_b64_string base64; + wg_key_to_base64(base64, encap.encap); - l = bsprintf(pos, "%02x ", data[i]); + l = bsnprintf(pos, size, "%s", base64); ADVANCE(pos, size, l); + } else { + for (uint i = 0; i < encap.encap_len; i++) { + if (size < 4) { + return pos - buf; + } + + l = bsnprintf(pos, size, "%02x ", data[i]); + ADVANCE(pos, size, l); + } } } |