Files
lmvpn_client/internal/paths/paths.go
T
kevin 65a5932eba feat: 支持 Windows x86_64 平台编译
- 新增 WinTun TUN 设备实现(tun_windows.go),无需安装驱动,
  wintun.dll 嵌入 exe 运行时自动释放
- 新增 Windows 路由管理(route_windows.go),使用 route/netsh 命令
- 新增 Windows 路径(paths_windows.go),使用 %APPDATA%/%LOCALAPPDATA%
- 拆分 daemon 启动逻辑:launch_unix.go(Setsid) / launch_windows.go
  (CREATE_NEW_PROCESS_GROUP),公共代码提取到 launch_common.go
- 拆分提权逻辑:elevation_darwin.go(osascript) / elevation_windows.go
  (ShellExecute UAC) / elevation_other.go(pkexec)
- IPCSocketPath 按平台分散,Windows 用 %TEMP%\lmvpn.sock
- daemon 二进制名用编译时常量(daemonBinaryName),按平台选定 .exe 后缀
- Makefile 新增 build-windows 目标
- 重新标记 !darwin 文件为 !darwin && !windows
2026-07-07 16:50:42 +08:00

61 lines
1.8 KiB
Go

// Package paths resolves platform-specific application directories.
//
// Layout follows each platform's conventions. On macOS:
//
// ~/Library/Application Support/com.lmvpn.client/ user data, db, config
// ~/Library/Caches/com.lmvpn.client/ caches
// ~/Library/Logs/com.lmvpn.client/ logs
package paths
import "os"
// BundleID is the application bundle identifier used as the per-app
// subdirectory name under the platform library folders.
const BundleID = "com.lmvpn.client"
// AppName is the human-readable application name.
const AppName = "LMVPN"
// Dirs describes the resolved application directories.
type Dirs struct {
Data string // persistent user data (db, config)
Cache string // recreatable caches
Log string // log files
}
// Paths is the resolved directory set for the current platform.
var Paths Dirs
// SetUserHome overrides the home directory used to compute Paths.
// This is used by the daemon (which runs as root) to write logs and
// data to the invoking user's Library folders instead of /var/root.
func SetUserHome(home string) {
if home != "" {
recomputePaths(home)
}
}
// EnsureDirs creates the application directories if they do not exist.
func EnsureDirs() error {
for _, d := range []string{Paths.Data, Paths.Cache, Paths.Log} {
if err := os.MkdirAll(d, 0o755); err != nil {
return err
}
}
return nil
}
// DBPath returns the path to the SQLite database file.
func DBPath() string { return Paths.Data + "/lmvpn.db" }
// ConfigPath returns the path to the application config file.
func ConfigPath() string { return Paths.Data + "/config.yml" }
// LogFile returns the path to the GUI log file.
func LogFile() string { return Paths.Log + "/lmvpn.log" }
// DaemonLogFile returns the path to the daemon log file.
func DaemonLogFile() string { return Paths.Log + "/lmvpn-daemon.log" }