- 新增竞速拨号器(racedial.go):域名连接时并行解析所有A/AAAA记录, 同时对所有IP发起TCP连接,第一个成功的胜出,确保选择延迟最低的地址 - ServerProfile新增IPPreference字段(auto/v4/v6),支持用户指定IP版本偏好 - 填写服务器IP时跳过域名解析直接使用IP,顺序failover - 连接成功后状态栏显示「已连接 (域名 -> 实际IP)」 - DB迁移v6:server_profiles表添加ip_preference列 - WebSocket拨号与HTTP登录均使用竞速拨号器 - 补充中英文i18n翻译
59 lines
1.8 KiB
Go
59 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" }
|