Expand description
Utility functions for formatting and path management.
This module provides helper functions for common operations like formatting byte rates, durations, and managing configuration directories.
Structs§
- Profile
Metadata - Profile metadata for persistence
Functions§
- cleanup_
openvpn_ run_ files - Cleans up
OpenVPNruntime files (pid, log) for a given profile. - create_
user_ dir - Create a directory (and parents) owned by the real user.
- delete_
openvpn_ auth_ file - Deletes the saved
OpenVPNauth credentials file for a profile. - delete_
openvpn_ scrv1_ auth_ file - Delete the static-challenge SCRV1 auth file for a profile if present.
- format_
bytes_ speed - Formats bytes per second into a human-readable string.
- format_
local_ time - Returns the current local time formatted as HH:MM:SS.
- format_
relative_ time - Formats a
SystemTimeinto a compact relative time string (e.g., 1s, 2m, 3h, 4d). - format_
system_ time_ local - Converts any
SystemTimeinto a localHH:MM:SSstring. - get_
app_ config_ dir - Returns the application configuration directory path.
- get_
openvpn_ auth_ path - Returns the path for an
OpenVPNauth credentials file. - get_
openvpn_ run_ paths - Returns
(pid_path, log_path)for the given profile name. - get_
openvpn_ scrv1_ auth_ path - Path of the transient SCRV1 envelope auth file used for static-challenge connects (plan 2026-06-02-001 U3 / PF-2, #191).
- get_
profiles_ dir - Returns the VPN profiles directory path.
- get_
tmp_ config_ dir - Returns the per-session temp config directory
${config_dir}/tmp/${session_id}/. - get_
unique_ path - Returns a unique path by appending (n) if the file already exists.
- home_
dir - Returns the user’s home directory.
- is_
private_ ip - Checks if an IP address belongs to a private network range (RFC1918).
- is_root
- Check if the current process is running as root (UID 0)
- load_
profile_ metadata - Load profile metadata from disk
- openvpn_
config_ needs_ auth - Checks whether an
OpenVPNconfig file containsauth-user-passwithout a file argument. - read_
openvpn_ pid - Reads the PID from an
OpenVPNpid file. - read_
openvpn_ saved_ auth - Reads saved
OpenVPNcredentials from the auth file. - read_
openvpn_ static_ challenge_ prompt - Read a .ovpn config and return the
static-challengeprompt text if the directive is present. - sanitize_
profile_ name - Returns the
OpenVPNruntime directory path for a given profile. - save_
profile_ metadata - Save profile metadata to disk
- scrub_
stale_ scrv1_ auth_ files - Scan the
OpenVPNauth directory and delete any leftover transient<safe>.scrv1.authcredentials bundle (plan 2026-06-02-001 U6, #191). - truncate
- Truncates a string to a maximum number of characters.
- write_
openvpn_ auth_ file - Write the canonical
<safe>.authcredentials file: line 1 username, line 2 password, both in plain text. - write_
openvpn_ scrv1_ auth_ file - Write a transient 3-line credentials bundle for the
OpenVPNmanagement-socket auth flow (plan 2026-06-02-001, #191, Approach B-minimal). The protocol layer reads this file, drives the--managementsocket dance with the embedded user/pass/otp, then deletes the file. Each line is<value>followed by\n: - write_
user_ file - Write a file owned by the real user.