Commit Graph

11 Commits (main)

Author SHA1 Message Date
dadevel 121288feb9
add exec command 4 weeks ago
UpYoursMicrosoft 150a052211
support moving interfaces into default netns
Closes #23.
2 months ago
Dmitry Vodopyanov 5a3d297d82
handle empty ip netns output
This patch fixes the crash which happens during execution of `wg-netns list`.
The crash happens if nothing else from `wg-netns` is executed on machine yet,
i.e., after the reboot. In that case, `ip -json netns` returns an empty string,
not `[]`, so we get an exception if we pass empty line into `json.loads()`.

```
$ export WG_VERBOSE=1
$ /home/user/.local/bin/wg-netns list
> ip -json netns
error: Expecting value: line 1 column 1 (char 0) (JSONDecodeError)
Traceback (most recent call last):
  File "/home/user/.local/bin/wg-netns", line 391, in <module>
    main()
  File "/home/user/.local/bin/wg-netns", line 27, in main
    cli(sys.argv[1:])
  File "/home/user/.local/bin/wg-netns", line 93, in cli
    data = json.loads(output)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```
5 months ago
Rafael Ristovski b0e7fcdda8
retrieve current username correctly
`os.getlogin()` does not work in some cases, however `getpass.getuser()` does.
Closes #17.
12 months ago
dadevel 1d1c87dd13
configure wg interface in base netns
Resolves #12.
12 months ago
dadevel 0e55f3fcf8
resolve type linting errors 12 months ago
Alex Leigh eff7413c79 make private key optional
Allows private keys to be set in a post-up command and left out of config files.
1 year ago
Jendrik Weise 6486b2fad1 add base_netns functionality
Allows to specify the netns in which the WireGuard interface
is initialized. This allows for multi-hop VPNs.
1 year ago
dadevel 41665ca136
add list and switch commands 2 years ago
Chris Bouchard 56a9e4fbe6
add option to run shell hooks in host netns
Closes #6.
2 years ago
dadevel baa1d01a49
package with poetry 2 years ago