baseline: api+gui traffic mode + candidates picker
Snapshot before app-launcher (cgroup/mark) work; ignore binaries/backups.
This commit is contained in:
52
selective-vpn-api/app/routes_units.go
Normal file
52
selective-vpn-api/app/routes_units.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user