Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
requests<3.0
libcnml<0.10.0
openvpn-status-reader>=0.3,<0.4
openvpn-status-reader @ https://github.com/openwisp/openvpn-status-reader/archive/refs/heads/fix/openvpn-status-peer-prefixes.tar.gz
networkx>=3.6.1,<3.7
telnetlib3>=5.0.1,<6
16 changes: 16 additions & 0 deletions tests/static/openvpn-transport-prefixes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OpenVPN CLIENT LIST
Updated,2026-10-24 12:00:00
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
udp4-client,udp4:181.126.36.3:1194,1,2,2026-10-24 11:00:00
tcp4-client,tcp4:181.126.36.4:1194,3,4,2026-10-24 11:01:00
udp6-client,udp6:[2001:db8::3]:1194,5,6,2026-10-24 11:02:00
tcp6-client,tcp6:[2001:db8::4]:1194,7,8,2026-10-24 11:03:00
ROUTING TABLE
Virtual Address,Common Name,Real Address,Last Ref
10.0.0.3,udp4-client,udp4:181.126.36.3:1194,2026-10-24 11:00:01
10.0.0.4,tcp4-client,tcp4:181.126.36.4:1194,2026-10-24 11:01:01
2001:db8:1::3,udp6-client,udp6:[2001:db8::3]:1194,2026-10-24 11:02:01
2001:db8:1::4,tcp6-client,tcp6:[2001:db8::4]:1194,2026-10-24 11:03:01
GLOBAL STATS
Max bcast/mcast queue length,0
END
22 changes: 22 additions & 0 deletions tests/test_openvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
links5_tap = open("{0}/static/openvpn-5-links-tap.txt".format(CURRENT_DIR)).read()
bug = open("{0}/static/openvpn-bug.txt".format(CURRENT_DIR)).read()
special_case = open("{0}/static/openvpn-special-case.txt".format(CURRENT_DIR)).read()
transport_prefixes = open(
"{0}/static/openvpn-transport-prefixes.txt".format(CURRENT_DIR)
).read()


class TestOpenvpnParser(TestCase):
Expand Down Expand Up @@ -91,6 +94,25 @@ def test_empty_dict(self):
def test_empty_string(self):
OpenvpnParser(data="")

def test_transport_prefixed_peers(self):
data = OpenvpnParser(transport_prefixes).json(dict=True)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
nodes = {
node["properties"]["common_name"]: node
for node in data["nodes"]
if "common_name" in node["properties"]
}

for common_name, address, port in [
("udp4-client", "181.126.36.3", 1194),
("tcp4-client", "181.126.36.4", 1194),
("udp6-client", "2001:db8::3", 1194),
("tcp6-client", "2001:db8::4", 1194),
]:
with self.subTest(common_name=common_name):
properties = nodes[common_name]["properties"]
self.assertEqual(properties["real_address"], address)
self.assertEqual(properties["port"], port)

def test_label_diff_added(self):
old = OpenvpnParser({})
new = OpenvpnParser(links5_tap)
Expand Down
Loading