diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-03-02 23:11:47 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-09-13 18:05:34 +0200 |
commit | 1b251a43df807c0c9b362a56233784dc7bbe9629 (patch) | |
tree | bdb12806c7c3dceaf70ba9f522e34a4747cea968 /proto/wireguard | |
parent | 5eb135b55f3a27a25b772e19c97b68ac17931f0c (diff) |
Wireguard: Add remote endpoint
Diffstat (limited to 'proto/wireguard')
-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; |