summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-02 23:11:47 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2020-05-08 18:52:55 +0200
commitaec202880edc24cfd1abe281787e6d7e74ee3b85 (patch)
tree748d0bc7eb6c4c66a40ccd152c2fea92305e3384 /proto
parente5a72c3b4fc1fb09102cb4923849ffc8488ac240 (diff)
Wireguard: Add remote endpoint
Diffstat (limited to 'proto')
-rw-r--r--proto/wireguard/wireguard.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c
index d517c7f4..f209665e 100644
--- a/proto/wireguard/wireguard.c
+++ b/proto/wireguard/wireguard.c
@@ -269,7 +269,21 @@ wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n,
ip6_addr addr = ip6_hton(net6_prefix(n->n.addr));
memcpy(allowedip->ip6.s6_addr, &addr, 16);
}
-
+
+ if (udp_dest_port != 0 && ipa_nonzero(remote_ep_addr) ) {
+ if (ipa_is_ip4(remote_ep_addr)) {
+ log(L_TRACE "WG: found ip4 ep");
+ peer->endpoint.addr4.sin_family = AF_INET;
+ put_ip4(&peer->endpoint.addr4.sin_addr.s_addr, ipa_to_ip4(remote_ep_addr));
+ put_u16(&peer->endpoint.addr4.sin_port, udp_dest_port);
+ } else {
+ log(L_TRACE "WG: found ip6 ep");
+ peer->endpoint.addr6.sin6_family = AF_INET6;
+ put_ip6(&peer->endpoint.addr6.sin6_addr, ipa_to_ip6(remote_ep_addr));
+ put_u16(&peer->endpoint.addr6.sin6_port, udp_dest_port);
+ }
+ }
+
allowedip->cidr = net_pxlen(n->n.addr);
peer->last_allowedip->next_allowedip = allowedip;
peer->last_allowedip = allowedip;