unixconn

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 4 Imported by: 0

README

UnixConn tools

Some stuff commonly used made more simple.

socketpair

Calling

	pair, err := unixconn.Pair()

Allows pair to contain two *net.UnixConn that are connected to each other. Those can be used as replacement to TCP connections in test code, for example.

cred

Golang already makes this easier thanks to GetsockoptUcred but I feel this can be even better.

	uid, gid, pid, err := unixconn.Cred(c)

NOTE: Using unixconn.Cred() on a connection generated by unixconn.Pair() will return the information at the time the call to Pair() happened, and may not reflect the right information if for example the socket was passed to a child process.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cred

func Cred(c net.Conn) (uid, gid, pid int, err error)

Cred returns details on the connected unix connection, useful for identifying the connecting process.

func Pair

func Pair() ([]*net.UnixConn, error)

Pair will return a pair of interconnected sockets that can be used for testing and more.

Types

This section is empty.

Jump to

Keyboard shortcuts

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