Conversation
share/completions/wg-quick.fish
Outdated
| set -l valid_subcmds up down strip save | ||
|
|
||
| function __wg_complete_interfaces | ||
| wg show 2>| string replace -rf 'Unable to access interface (.*): Operation not permitted' '$1' |
There was a problem hiding this comment.
Ooof, this seems... awkward. Is there really no better way than to parse an error message?
If you get an error message, is the argument actually useful?
There was a problem hiding this comment.
wg-quick looks for interfaces in /etc/wireguard/, which has 700 permissions so we cannot get completion candidates from there. This was the only way I could find that works - however I guess will need to prefix with LC_ALL=C too. wg show always shows the name of the currently connected interface in its error message, so it is perfect as the completion in this case.
There was a problem hiding this comment.
wg-quick looks for interfaces in /etc/wireguard/, which has 700 permissions so we cannot get completion candidates from there.
Okay, wait... what happens if you are the owner (I'm assuming root?)?
What does wg show say then?
There was a problem hiding this comment.
Ping @ammgws: Does this work if you're root? I'm assuming it doesn't error out then, but do the completions still work?
There was a problem hiding this comment.
@faho Sorry for the late reply. It doesn't error out, just gives garbage candidates for the completion:
>root@mydesktop ~# wg-quick down [TAB]
allowed ips: 0.0.0.0/0, ::/0 private key: (hidden)
endpoint: xxx:51820 public key: xxxx
fwmark: 0xca6c transfer: 414.65 KiB received, 141.07 KiB sent
latest handshake: 50 seconds ago interface: my_wg_interface
listening port: 49937 peer: xxxxThis is what it should parse when root to get the interface name:
>wg show interfaces
my_wg_interfaceThere was a problem hiding this comment.
Actually it looks like that works for non-root too, so we can just get rid of the kluge altogether:
>wg show
Unable to access interface mlvd-ch2: Operation not permitted
[1]>wg show interfaces
my_wg_interface|
On Tue, Feb 08, 2022 at 08:56:14PM -0800, Jason Nader wrote:
+function __wg_complete_interfaces
I think we want to name this __fish_wg_complete_interfaces
|
|
Merged, thanks! |
|
Sorry I never got around to checking what happens when you're |
Description
Adds completions for the Wireguard
wg-quickutility.Fixes issue #
TODOs: