summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-02 23:11:47 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-11-15 00:11:29 +0100
commit091d6ad938c00813dc243a571221a67ed1f674fa (patch)
treedb75b92ef2ead0c75f6fafab951c782f62dd5e6c
parente5b71a15ae6b0bb6815dda214f0df9175c5e684e (diff)
Wireguard: Add remote endpoint
-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;