diff options
-rw-r--r-- | proto/wireguard/wireguard.c | 16 |
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; |