Skip to content

[bug] WireGuard backend is missing parsers  #276

Todo
rohanesor/netjsonconfig
#1

Description

@pandafy

The WireGuard backend does not implement parsers.

class WireguardParser(BaseParser):
def parse_text(self, config):
raise NotImplementedError()
def parse_tar(self, tar):
raise NotImplementedError()
def _get_vpns(self, text):
raise NotImplementedError()
def _get_config(self, contents):
raise NotImplementedError()

We need to add parsers like OpenVPN backend.

Activity

  1. rohanesor commented on Oct 22, 2026

    @rohanesor

    I'd like to work on this.

    Current state on master:

    • 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:

    1. 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.
    2. 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.
    3. 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.

  2. openwisp-companion commented on Oct 22, 2026

    @openwisp-companion

    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.

  3. added 2 commits that reference this issue on Oct 25, 2026
  4. openwisp-companion commented on Nov 23, 2026

    @openwisp-companion

    This issue has been automatically assigned to @rohanesor, who opened PR #441. 🎯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions