Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split config sections based on entire line #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marksteward
Copy link

Currently you'll get the following error if parsing a config file with a commented out peer:

Traceback (most recent call last):
  File "<python-input-1>", line 2, in <module>
    config = WireguardConfig.from_wgconfig(fh)
  File "/usr/local/lib/python3.13/site-packages/wireguard_tools/wireguard_config.py", line 239, in from_wgconfig
    peer = WireguardPeer.from_wgconfig(key_value)
  File "/usr/local/lib/python3.13/site-packages/wireguard_tools/wireguard_config.py", line 132, in from_wgconfig
    return cls(**conf)
TypeError: WireguardPeer.__init__() missing 1 required positional argument: 'public_key'

This PR fixes it by only matching full lines for section headings.

Allows ignoring of commented-out peers.
@marksteward
Copy link
Author

Technically we should be checking all lines for comments, and allowing inline comments after the sections too, but I'm not sure how rigorous we should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant