Skip to main content

Manage Wireguard configuration files

Project description

wg_conf

GitHub PyPI

Python library to read, edit, and save Wireguard configuration files

Installation

Install using pip:

python3 -m pip install wg-conf

Methods

Load a configuration file:

import wg_conf

wc = wg_conf.WireguardConfig('/etc/wireguard/wg0.conf')

Write a configuration file to disk:

wc.write_file()
Edit the interface

Add an attribute to the interface

wc.add_interface_attr('AttributeKey', 'AttributeValue')

add_interface_attr will not overwrite an existing attribute. If you are sure you want to overwrite an existing attribute, use set_interface_attr with the same parameters. Otherwise, an Exception will be thrown if you try to overwrite an existing attribute

Remove an attribute from the interface

wc.del_interface_attr('AttributeKey')

If no matching attribute is found, no change will be made

Edit a peer

Add an attribute to a peer

wc.add_peer_attr('PeerPublicKey', 'AttributeKey', 'AttributeValue')

add_peer_attr will not overwrite an existing attribute. If you are sure you want to overwrite an existing attribute, use set_peer_attr with the same parameters. Otherwise, an Exception will be thrown if you try to overwrite an existing attribute

Remove an attribute from a peer

wc.del_interface_attr('PeerPublicKey', 'AttributeKey')

If no matching peer or attribute is found, no change will be made

Create or remove a peer

Create a peer given a public key:

wc.create_peer('PeerPublicKey')

You can now use add_peer_attr to configure the peer as you wish

Delete a peer given a public key:

wc.del_peer('PeerPublicKey')

Build pypi package

Build a binary and source distribution for pypi

python3 setup.py sdist bdist_wheel

Push to pypi

python3 -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wg_conf-0.9.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wg_conf-0.9.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file wg_conf-0.9.1.tar.gz.

File metadata

  • Download URL: wg_conf-0.9.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3

File hashes

Hashes for wg_conf-0.9.1.tar.gz
Algorithm Hash digest
SHA256 94600ed41be4ff4dbb21f3c73db7337b174e2a00adf9d309157f538f123590a7
MD5 89be2e1b3e405326db49cd5c26ea4114
BLAKE2b-256 52d74efd6d9fdcae9733b251c1919d86b1c94efb2fc4bd416caccc0c1bd1f838

See more details on using hashes here.

File details

Details for the file wg_conf-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: wg_conf-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3

File hashes

Hashes for wg_conf-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7242c4c47ae38c5d0c70bea93e9d358a0ae2f6320e193bfa9456603395057709
MD5 acf5d5c21d9d373febe5eec0cc2ec09a
BLAKE2b-256 46b521626fc89607598c2e8c262395649e64fa90ce93aed56aa0e7db4c938ad5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page