You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
backends/wireguard/parser.py — WireguardParser raises NotImplementedError() for parse_text(), parse_tar(), _get_vpns() and _get_config().
backends/wireguard/converters.py — Wireguard defines _forward_property_map and to_intermediate_loop(), but there is no backward (to_netjson) path, so parsing alone would not be enough to produce NetJSON.
So the work is: implement the parser, then the backward conversion, mirroring how the OpenVPN backend does it.
One difference worth flagging early: OpenVPN's native format is flat key value lines, which is why its _get_config() can use a single config_pattern regex. WireGuard is INI-style with [Interface] and repeatable [Peer] sections, so the parsing has to be section-aware and map [Peer] blocks onto the peers list rather than onto top-level keys. I plan to parse the sections explicitly instead of reusing config_pattern.
My plan:
Implement parse_text() / parse_tar() / _get_vpns() / _get_config() so a .conf (or tarball of .conf files) becomes the intermediate representation, keeping the existing vpn_pattern and config_suffix conventions.
Add the backward conversion in the converter, deriving it from the inverse of _forward_property_map, including the dns comma-join, the save_config boolean and the peer properties.
Add round-trip tests: render a config to native, parse it back, and assert the NetJSON matches — plus tests for a bare [Interface], multiple [Peer] sections and the tarball path.
Two questions before I start:
Unknown keys: if a parsed .conf contains a directive which is not in the schema, should the parser drop it, or preserve it so it survives a round trip? The OpenVPN parser keeps unrecognised directives; I'd mirror that unless you'd prefer strict schema validation.
Scope: should this stay limited to the WireGuard backend, or do you also want the same treatment for the VXLAN-over-WireGuard backend in the same PR? I'd default to WireGuard only, to keep the PR reviewable.
Happy to adjust if you'd rather the approach went a different way.
Activity
rohanesor commentedon Oct 22, 2026
I'd like to work on this.
Current state on
master:backends/wireguard/parser.py—WireguardParserraisesNotImplementedError()forparse_text(),parse_tar(),_get_vpns()and_get_config().backends/wireguard/converters.py—Wireguarddefines_forward_property_mapandto_intermediate_loop(), but there is no backward (to_netjson) path, so parsing alone would not be enough to produce NetJSON.So the work is: implement the parser, then the backward conversion, mirroring how the OpenVPN backend does it.
One difference worth flagging early: OpenVPN's native format is flat
key valuelines, which is why its_get_config()can use a singleconfig_patternregex. WireGuard is INI-style with[Interface]and repeatable[Peer]sections, so the parsing has to be section-aware and map[Peer]blocks onto thepeerslist rather than onto top-level keys. I plan to parse the sections explicitly instead of reusingconfig_pattern.My plan:
parse_text()/parse_tar()/_get_vpns()/_get_config()so a.conf(or tarball of.conffiles) becomes the intermediate representation, keeping the existingvpn_patternandconfig_suffixconventions._forward_property_map, including thednscomma-join, thesave_configboolean and the peer properties.[Interface], multiple[Peer]sections and the tarball path.Two questions before I start:
.confcontains a directive which is not in the schema, should the parser drop it, or preserve it so it survives a round trip? The OpenVPN parser keeps unrecognised directives; I'd mirror that unless you'd prefer strict schema validation.Happy to adjust if you'd rather the approach went a different way.
openwisp-companion commentedon Oct 22, 2026
Hi @rohanesor 👋,
Thanks for your interest in contributing to OpenWISP!
If nobody is assigned to this issue, you can start working.
Open a draft pull request linked to this issue, for example
Fixes #276.Join the developer chat to coordinate or ask questions.
[fix] Added parsers to the WireGuard backend openwisp#276
Merge pull request #1 from rohanesor/fix/276-wireguard-parser
openwisp-companion commentedon Nov 23, 2026
This issue has been automatically assigned to @rohanesor, who opened PR #441. 🎯
[fix] Added parsers to the WireGuard backend openwisp#276
[fix] Handled inline comments and repeated directives in WireGuard pa…
[fix] Ignored empty values and duplicate DNS servers in WireGuard par…
[fix] Matched WireGuard directive names case-insensitively openwisp#276
[fix] Kept additional files and unmarked input out of WireGuard parsing