pathsocket

package
v0.0.0-...-57c9ba2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package pathsocket is a helper library to facilitate dealing with unix domain sockets and named pipes (unix domain socket on *nix and pipes on windows). It provides a unified abstraction on top, so code would compile and work fine on both family of operating systems.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathCred is a context key that is used when saving Ucred information into the context.
	PathCred = &ContextKey{"path-creds"}
)

Functions

func GetSocketPath

func GetSocketPath(dir string, pipeName string) string

GetSocketPath is a helper function for unit tests so we can run them platform agnostic

func NewDialer

func NewDialer(socketPath string, flags ...DialFlag) common.Upstream

NewDialer creates a new Upstream interface to a path listener.

func NewListener

func NewListener(socketPath string, params string) (common.Listener, error)

NewListener creates a new unix domain socket listener Params is platform specific and optional (empty string is ok). On unix, the following parameters are supported (separated by `:`): - permission (filemode e.g. 0660) - userName (e.g. root) - groupName (e.g. sudoers) The default permission is 0600. The default userName and groupName is "-" which means chown is not executed (the listener inode is owned by the current process).

func RetrieveConnectionInfo

func RetrieveConnectionInfo(conn net.Conn) (any, error)

RetrieveConnectionInfo retrieves info about the connection. On unix, this returns *ResolvedUcred - ucred information along with the Uid and Gid resolved into their textual representation. On other platforms currently, it returns nil.

Types

type ContextKey

type ContextKey struct {
	Name string
}

ContextKey is root type of info that is added into the context.

type DialFlag

type DialFlag int

DialFlag allows customizing the dialing behaviour.

const (
	// Grpc indicates that the upstream is a Grpc listener
	Grpc DialFlag = 1
)

type PathUpstream

type PathUpstream struct {
	// contains filtered or unexported fields
}

PathUpstream implements the Upstream interface to access the containerd listener.

func (*PathUpstream) Dial

func (us *PathUpstream) Dial() (net.Conn, error)

Dial establishes a connection to the unix domain socket of containerd.

type ResolvedUcred

type ResolvedUcred struct {
	Pid      int32
	Uid      uint32
	Gid      uint32
	Username string
	Group    string
}

ResolvedUcred is the expanded version of Ucred that features the resolved Username/Group names as well. Initialism: style is aligned with the upstream struct unix.Ucred

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL