# WireGuard connection issues since v1.30.3221.67

**URL:** <https://forum.pritunl.com/t/wireguard-connection-issues-since-v1-30-3221-67/2023>\
**Category:** Pritunl\
**Tags:** pritunl\
**Created:** [April 30, 2024, 6:14am UTC](https://forum.pritunl.com/t/wireguard-connection-issues-since-v1-30-3221-67/2023 "2024-04-30T06:14:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorenzo](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lorenzo](https://forum.pritunl.com/u/lorenzo)\
**Post date:** [April 30, 2024, 6:14am UTC](https://forum.pritunl.com/t/wireguard-connection-issues-since-v1-30-3221-67/2023/1 "2024-04-30T06:14:26Z")

</div>

Hi Team,

When I try to connect using Wireguard to our VPN servers the connection fails since upgrade to v1.30.3221.67. After some investigation, the issue appears to be in the pritunl/handlers/key.py \> key\_wg\_post method (POST /key/wg/\<org\_id\>/\<user\_id\>/\<server\_id\> handler) [here](https://github.com/pritunl/pritunl/blob/420012b9daaa1085a3db7bd2825c23a14377fa65/pritunl/handlers/key.py#L1051).

The if condition checks if the **remote\_addr** is IPv6 by relying on the presence of ‘:’ character, however in our case the **remote\_addr** variable contains the port as well, e.g. 11.22.33.44:12345. Because the code checks for ‘:’ it gets interpreted as IPv6, failing the connection with WireGuard. The stacktrace is the following:

` File "/usr/lib/pritunl/usr/lib/python3.9/site-packages/pritunl/handlers/key.py", line 1059, in key_wg_post`  
` remote_addr = str(ipaddress.IPv6Address(remote_addr))`  
` File "/usr/lib/pritunl/usr/lib/python3.9/ipaddress.py", line 1915, in __init__ `  
` self._ip = self._ip_int_from_string(addr_str)`  
` File "/usr/lib/pritunl/usr/lib/python3.9/ipaddress.py", line 1628, in _ip_int_from_string`  
` raise AddressValueError(msg)`  
`ipaddress.AddressValueError: At least 3 parts expected in '11.22.33.44:12345'`

Could you please advise if this is something incorrectly configured on our side or might be a bug in the IPv6 condition check?

Thanks

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [April 30, 2024, 9:40pm UTC](https://forum.pritunl.com/t/wireguard-connection-issues-since-v1-30-3221-67/2023/2 "2024-04-30T21:40:32Z")

</div>

This will be fixed in the next release. The change can be applied to `/usr/lib/pritunl/usr/lib/python3.9/site-packages/pritunl/utils/network.py` by adding the `strip_port` function and modifying the `get_remote_addr` function.

```auto
def strip_port(hostport):
    colon = hostport.find(':')
    if colon == -1:
        return hostport

    if ']' in hostport:
        i = hostport.find(']')
        if i != -1:
            return hostport[:i].lstrip('[')

    return hostport[:colon]

def get_remote_addr():
    if settings.app.reverse_proxy:
        forward_ip = flask.request.headers.get('PR-Forwarded-Header')
        if forward_ip:
            return strip_port(forward_ip.split(',')[-1].strip())

    forward_ip = flask.request.headers.get('PR-Forwarded-For')
    if forward_ip:
        return strip_port(forward_ip)

    return strip_port(flask.request.remote_addr)

```

---

<div class="post-metadata">

**Author:** ![lorenzo](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lorenzo](https://forum.pritunl.com/u/lorenzo)\
**Post date:** [May 1, 2024, 5:28am UTC](https://forum.pritunl.com/t/wireguard-connection-issues-since-v1-30-3221-67/2023/3 "2024-05-01T05:28:45Z")

</div>

Hi zach,

Thank you for your reply and taking this up in the next release.

Something perhaps to consider with this change is that currently all the journal logs contain the IP:PORT in the User’s Audit log visible from Pritunl UI and in the Journal as well:

- [User audit event](https://github.com/pritunl/pritunl/blob/420012b9daaa1085a3db7bd2825c23a14377fa65/pritunl/handlers/key.py#L1151)
- [Journal entry](https://github.com/pritunl/pritunl/blob/420012b9daaa1085a3db7bd2825c23a14377fa65/pritunl/handlers/key.py#L1154C5-L1154C12)

By stripping the port it will not be logged anymore along with the IP address, not sure if this might be a problem?

I also find it quite useful having the port along with the IP address in the Users Audit logs.

Thank you

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [May 8, 2024, 10:16pm UTC](https://forum.pritunl.com/t/wireguard-connection-issues-since-v1-30-3221-67/2023/4 "2024-05-08T22:16:00Z")

</div>

The port is a NAT port that is isn’t intended to be included in those records.
