Fix wireguard integrations for 4.8.x - #21
Conversation
|
@HarvsG I have added versioning by passing a version string, usually gathered from the I've also added tests that use the new API and tests for starting and stopping. Anyone with an old device could run these tests to make sure everything works. I can confirm that it works on 4.8.1. |
|
|
||
| if self._firmware_version < NEW_VPN_CLIENT_VERSION: | ||
| # If the version is less than 4.8 we need to adjust the response to match the new format | ||
| # The old format does not return an array, but just a single object. |
|
I'm not sure what to do about most of the linting errors about mixed line endings. I fixed some whitespace issues and unnecessary else statements though. |
I'll fix them when I review tomorrow |
| async def wireguard_client_state(self) -> dict: | ||
| async def wireguard_client_state(self) -> list: | ||
| """ | ||
| {"rx_bytes":0,"ipv6":"","tx_bytes":0,"domain":"vpn.example.com","group_id":7707,"port":51820,"name":"TheOracle","peer_id":1341,"status":0,"proxy":True,"log":"","ipv4":""} |
There was a problem hiding this comment.
Can you check if this is true for modern firmware - as it seems you are using tunnel_id and ned peer_id
There was a problem hiding this comment.
What exactly do you want me to verify? Just so I understand.
But in-case you're referring to the comment being outdated, you'd be right.
Here's the full output of calling that endpoint on 4.8.1 (with some redactions)
{
"id": 7,
"jsonrpc": "2.0",
"result": {
"status_list": [
{
"enabled": true,
"type": "wireguard",
"tx_bytes": 24953488020,
"peer_name": "PEER NAME HERE",
"domain": [
"XXX.XXX.XXX.XXX"
],
"group_id": 1234,
"via": "wgclient1",
"port": 51820,
"tunnel_id": 10,
"rx_bytes": 49725356924,
"peer_id": 5678,
"status": 1,
"name": "Primary Tunnel",
"ipv4": "XXX.XXX.XXX.XXX"
}
],
"mode": 0
}
}Should I update the comment with the new response?
|
does 4.8 support more that one connection at once? |
According to their releases, yes: "Added VPN multi-instance, allowing support for enabling multiple VPN clients at the same time." |
|
Ok so HarvsG/ha-glinet4-integration#66 now works with these API changes and hopefully adds support for multiple wg clients simultaneously. I've done quite an ugly change to the WG api calls and to use peer_id and tunnel_id interchangeably Can you test your system with this PR and the above PR and confirm it works |
|
I am getting a seemingly unrelated issue with an index out of bounds error on this line which stops me from testing. Printing the output of |
list(DeviceInterfaceType) turns the strenum defined at the top into a list with 7 items. Which means it's not the 5 that is out of bounds but dev_info.get("type") (aka dev_info['type']) that is too large. Debug dev_info and see. It may be that your device has a new interface type that has been added to the API |
|
Ah, I see now. This router has a 6Ghz network, which is not listed. It returns as type 11. There's also WiFi 7, which I have disabled (and believe was disabled by default?) I guess my phone just didn't use the 6Ghz network before when I set this up? Because now it does and that causes the issue. Update: I enabled WiFi 7 / MLO WiFi (which I honestly don't know how it works), and that returns type 9. I do not know what type 8 and 10 are. Update 2: I went ahead and tested and other networks. I can not find network type 8, but found 9 (MLO), 10 (MLO Guest), 11 (6Ghz), and 12 (6Ghz Guest). I can make a separate pull request for that later. I can now test these actual changes and will post on the PR you linked. |
The diff for what exactly? I'm sorry, but I'm not quite following what you mean. If you're talking about the network interfaces, I made a pull request to the other repo. HarvsG/ha-glinet4-integration#67 |
This fixes the WireGuard calls to the correct endpoints as of version 4.8.1. This is a breaking change and will no longer support anything below 4.8. While it's possible to support older versions, it would add more code to maintain to route each call to the correct version.
This can be used to fix HarvsG/ha-glinet4-integration#57, which I also have a fix for once this package gets a new updated published.