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')

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.0.tar.gz (3.0 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.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wg_conf-0.9.0.tar.gz
  • Upload date:
  • Size: 3.0 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.7.7

File hashes

Hashes for wg_conf-0.9.0.tar.gz
Algorithm Hash digest
SHA256 bd8445303a2d4e19b60ce48fb49ea4911d6599f529fa31ec5990cc139c73a4bd
MD5 64108cfa0746d61b647860a001673610
BLAKE2b-256 5266a4746fc3a80533966bc3d5c5e3c7c97119a8bc27ced9a4cb0bed8513feb9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wg_conf-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.7.7

File hashes

Hashes for wg_conf-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc308bfc39dc8ff9841326b2aa6aaa49734f0a76a4da9709b54228b6db513b9
MD5 9fd9ecd650438d04043a065fafe33f2d
BLAKE2b-256 8b11404beaf2de4e04182d20783e22bcfebd9335495d97bef8172a56cdae3d5d

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