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-03-08 00:11:47 +0100
commit195fb403784fc3a80297edf87d28579044fe3c07 (patch)
tree2b2490f8d78e159a8859f2a1d148495ee1de2435
parent53df8266978638dbb56f7798dbad49e3b0208455 (diff)
wireguard: Add remote endpointold/wireguard-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 a2769138..e6427f4b 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;