baseline: api+gui traffic mode + candidates picker

Snapshot before app-launcher (cgroup/mark) work; ignore binaries/backups.
This commit is contained in:
beckline
2026-02-14 15:32:25 +03:00
parent 50e2999cad
commit 10a10f44a8
55 changed files with 16488 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
package app
import (
"fmt"
"os"
"strings"
)
// ---------------------------------------------------------------------
// routes systemd unit name resolution
// ---------------------------------------------------------------------
// EN: Resolve routes service/timer unit names from preferred/active iface.
// EN: Env overrides still have top priority for custom deployments.
// RU: Вычисление имен unit для routes service/timer по preferred/active iface.
// RU: Для кастомных окружений сохраняется приоритет переменных окружения.
func resolveRoutesUnitIface() (string, string) {
st := loadTrafficModeState()
if pref := normalizePreferredIface(st.PreferredIface); pref != "" {
return pref, "preferred"
}
if statusIface := statusIfaceFromFile(); statusIface != "" && statusIface != "-" {
return statusIface, "status"
}
if active, reason := resolveTrafficIface(""); active != "" {
return active, reason
}
return "", "iface-not-found"
}
func routesServiceUnitName() string {
if forced := strings.TrimSpace(os.Getenv(routesServiceEnv)); forced != "" {
return forced
}
iface, _ := resolveRoutesUnitIface()
if iface == "" {
return ""
}
return fmt.Sprintf(routesServiceTemplate, iface)
}
func routesTimerUnitName() string {
if forced := strings.TrimSpace(os.Getenv(routesTimerEnv)); forced != "" {
return forced
}
iface, _ := resolveRoutesUnitIface()
if iface == "" {
return ""
}
return fmt.Sprintf(routesTimerTemplate, iface)
}