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.2.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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wg_conf-0.9.2.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.2.tar.gz
Algorithm Hash digest
SHA256 af02be8fe1d6bcab451b1b1dd482818858654578ea94db03eb6a2085783b902b
MD5 1f7e785568f0a047ba5dada3ee9939ea
BLAKE2b-256 d5543bd2b7a2c8d28771fb6f008ddb8a7d4825004870b70dee1bbb9ea18ce00a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wg_conf-0.9.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71ae100a8e9f0274ef1164cc05db4bb7a8b0babf001b7ce4b84541f4e0782d79
MD5 32394ced0fe9401ddf65ede7be5269a3
BLAKE2b-256 0c048a85fa2586f0cd510fce7c0455125b74d520087ceddd47e6a54123d71c86

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