Documentation
¶
Overview ¶
Package netns allows ultra-simple network namespace handling. NsHandles can be retrieved and set. Note that the current namespace is thread local so actions that set and reset namespaces should use LockOSThread to make sure the namespace doesn't change due to a goroutine switch. It is best to close NsHandles when you are done with them. This can be accomplished via a `defer ns.Close()` on the handle. Changing namespaces requires elevated privileges, so in most cases this code needs to be run as root.
Index ¶
- Variables
- func DeleteNamed(name string) error
- func Set(vj VjHandle) error
- type VjHandle
- func Get() (VjHandle, error)
- func GetFromName(name string) (VjHandle, error)
- func GetFromPath(path string) (VjHandle, error)
- func GetFromPid(pid int) (VjHandle, error)
- func GetFromThread(pid int, tid int) (VjHandle, error)
- func New() (VjHandle, error)
- func NewNamed(name string) (VjHandle, error)
- func None() VjHandle
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
func DeleteNamed ¶
Types ¶
type VjHandle ¶
type VjHandle int
func GetFromName ¶
func GetFromPath ¶
func GetFromPid ¶
func (*VjHandle) Close ¶
Close closes the NsHandle and resets its file descriptor to -1. It is only implemented on Linux.
func (VjHandle) IsOpen ¶
IsOpen returns true if Close() has not been called. It is only implemented on Linux and always returns false on other platforms.