wireguard-tools
wireguard-tools copied to clipboard
wg-quick: linux: use sed for trimming config lines
Bash's longest matching operators combined with extended globs is extremely slow for very large lines. There are probably very few people for which this is noticable but in a file with 800 AllowIPs on a single line it keeps wg-quick from stalling for 5s when performing operations.
I'm not sure about the portability of this to other platforms beyond gnu linux.
My understanding is the multiple -e
flag style is the most portable and available
on non-gnu systems but I have not tested.
I didnt see any performance regression but perhaps shelling out to sed is slower if your config has thousands of lines. I suspect its not.
Ah sorry right after I sent this i noticed there was a typo and that the non-greedy match in sed was not working...
Fixed up.