traffic: add per-app runtime app routing via cgroup marks

This commit is contained in:
beckline
2026-02-14 16:58:30 +03:00
parent 1fec4a51da
commit 90907219dc
10 changed files with 819 additions and 7 deletions

View File

@@ -185,6 +185,43 @@ type TrafficInterfacesResponse struct {
IfaceReason string `json:"iface_reason,omitempty"`
}
// ---------------------------------------------------------------------
// traffic app marks (per-app routing via cgroup -> fwmark)
// ---------------------------------------------------------------------
type TrafficAppMarksOp string
const (
TrafficAppMarksAdd TrafficAppMarksOp = "add"
TrafficAppMarksDel TrafficAppMarksOp = "del"
TrafficAppMarksClear TrafficAppMarksOp = "clear"
)
// EN: Runtime app marking request. Used by per-app launcher wrappers.
// RU: Runtime app marking запрос. Используется wrapper-лаунчером per-app.
type TrafficAppMarksRequest struct {
Op TrafficAppMarksOp `json:"op"`
Target string `json:"target"` // vpn|direct
Cgroup string `json:"cgroup,omitempty"`
TimeoutSec int `json:"timeout_sec,omitempty"` // only for add
}
type TrafficAppMarksResponse struct {
OK bool `json:"ok"`
Message string `json:"message,omitempty"`
Op string `json:"op,omitempty"`
Target string `json:"target,omitempty"`
Cgroup string `json:"cgroup,omitempty"`
CgroupID uint64 `json:"cgroup_id,omitempty"`
TimeoutSec int `json:"timeout_sec,omitempty"`
}
type TrafficAppMarksStatusResponse struct {
VPNCount int `json:"vpn_count"`
DirectCount int `json:"direct_count"`
Message string `json:"message,omitempty"`
}
type SystemdState struct {
State string `json:"state"`
}