package namespace import ( "os" "git.theodohertyfamily.com/wg-wrap/internal/paths" ) // Ops defines the set of operations required by the Manager to handle // namespace isolation, lifecycle, and synchronization. type Ops interface { IsIsolated() bool Bootstrap() error BootstrapJoin(pid int) error RegisterProcess(pm *paths.PathManager, profile string) error UnregisterProcess(pm *paths.PathManager, profile string) error PruneStalePids(pm *paths.PathManager, profile string) error IsLastProcess(pm *paths.PathManager, profile string) (bool, error) PinNamespace(pm *paths.PathManager, profile string) error UnpinNamespace(pm *paths.PathManager, profile string) error FindActiveProfilePid(pm *paths.PathManager, profile string) (int, error) AcquireProfileLock(pm *paths.PathManager, profile string) (*os.File, error) ReleaseProfileLock(file *os.File) } // linuxOps is the concrete implementation of Ops for Linux systems. type linuxOps struct{} // NewLinuxOps returns a new instance of the Linux-specific namespace operations. func NewLinuxOps() Ops { return &linuxOps{} } func (l *linuxOps) IsIsolated() bool { return IsIsolated() } func (l *linuxOps) Bootstrap() error { return Bootstrap() } func (l *linuxOps) BootstrapJoin(pid int) error { return BootstrapJoin(pid) } func (l *linuxOps) RegisterProcess(pm *paths.PathManager, profile string) error { return RegisterProcess(pm, profile) } func (l *linuxOps) UnregisterProcess(pm *paths.PathManager, profile string) error { return UnregisterProcess(pm, profile) } func (l *linuxOps) PruneStalePids(pm *paths.PathManager, profile string) error { return PruneStalePids(pm, profile) } func (l *linuxOps) IsLastProcess(pm *paths.PathManager, profile string) (bool, error) { return IsLastProcess(pm, profile) } func (l *linuxOps) PinNamespace(pm *paths.PathManager, profile string) error { return PinNamespace(pm, profile) } func (l *linuxOps) UnpinNamespace(pm *paths.PathManager, profile string) error { return UnpinNamespace(pm, profile) } func (l *linuxOps) FindActiveProfilePid(pm *paths.PathManager, profile string) (int, error) { return FindActiveProfilePid(pm, profile) } func (l *linuxOps) AcquireProfileLock(pm *paths.PathManager, profile string) (*os.File, error) { return AcquireProfileLock(pm, profile) } func (l *linuxOps) ReleaseProfileLock(file *os.File) { ReleaseProfileLock(file) }