Coder Social home page Coder Social logo

towalink / wgconfig Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 12.0 172 KB

parsing and writing WireGuard configuration files (comment preserving)

License: GNU Affero General Public License v3.0

Python 100.00%
wireguard wireguard-configuration vpn wireguard-vpn comment-preserving

wgconfig's Issues

Permission denied error

I try to use this in Django project but i encounter this error:
[Errno 13] Permission denied: '/etc/wireguard/wg0.conf'

how can i fix it?
thank you.

Licensing Question

I'm unfamiliar with the license you chose.

If I used this project, I understand I would need to attribute you that I'm using it, and make the source available upon request.

What I don't understand is, would I need to use the same license for the larger project, which uses your program, or would I be able to use your program, and license my program which uses your program anyway I want, as long as I.

Attribute you/this project, as well as make the source available

The formatting on this question is all wrong, if you don't understand what I'm asking, please let me know.

Documentation about wg-tools needing to be installed for wgexec.py

I wanted to check before doing a PR for documentation, but I don't believe there's any docs about needing the wg-tools (which isn't necessarily required to run wireguard since it's integrated into Linux kernels) to be installed for using wgexec.py.

While I know, and most people will know, it might not hurt to have it explicitly called out.

Do you have any preference for the specific location to call that out if I was to do a PR for this project? (that is if you're accepting PRs).

IndexError: string index out of range when del_attr(...)

If I run this code on a configfile - an unhandled exception occurs.

Traceback (most recent call last):
File "/home/erik/dwellir/wireguard-sub/wgconf.py", line 30, in
mana()
File "/home/erik/dwellir/wireguard-sub/wgconf.py", line 23, in mana
wc.del_attr(None,'ListenPort')
File "/home/erik/dwellir/wireguard-sub/venv/lib/python3.10/site-packages/wgconfig/init.py", line 248, in del_attr
if self.lines[i][0] == '#':
IndexError: string index out of range

It would be good to handle that exception and let a user know to have remove_leading_comments=False

import wgconfig

def removeAttr():
wc = wgconfig.WGConfig('./wg0.conf')
wc.read_file()
print(wc.interface)
# wc.del_attr(None,'PrivateKey')
wc.del_attr(None,'ListenPort', remove_leading_comments=False)
# wc.add_attr(None, 'PrivateKey', 'XXXXXXXXXXXXXXXXXXXXXXXXXXX=')
wc.write_file()

def removeAttrFail():
wc = wgconfig.WGConfig('./wg0.conf')
wc.read_file()
print(wc.interface)
# wc.del_attr(None,'PrivateKey')
wc.del_attr(None,'ListenPort')
# wc.add_attr(None, 'PrivateKey', 'XXXXXXXXXXXXXXXXXXXXXXXX=')
wc.write_file()

removeAttr()
removeAttrFail()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.