ocproxy
ocproxy copied to clipboard
Follow XDG specification for ~/.vpnns-NAME
This is a very simple request, and should be pretty easy to implement, but could vpnns
use the XDG Base Directory Specification for where it puts its state files? I think it would be as simple as replacing getenv("HOME")
in
https://github.com/cernekee/ocproxy/blob/c98f06d942970cdf35dd66ab46840f7d6d567b60/src/vpnns.c#L842
with
char* state_home = getenv("XDG_STATE_HOME");
if (!state_home || strlen(state_home) == 0) {
state_home = getenv("HOME");
strncat(state_home, "/.local/state",
sizeof(state_home) - strlen(state_home) - 1);
}
if (asprintf(&statedir, "%s/.vpnns-%s", getenv("HOME"), name) < 0)
Note that this might be improved as I haven't really done any serious projects in C before, but this takes into account the cases where the variable is set to the empty string as well.