net-peercredlistener icon indicating copy to clipboard operation
net-peercredlistener copied to clipboard

A net.Listener implementation leveraging Unix domain socket features to reliably identify client processes.

peercredlistener

import "toolman.org/net/peercredlistener"

  • Overview
  • Index
  • Subdirectories

Overview

Package peercredlistener is deprecated in favor of toolman.org/net/peercred.

Index

  • Constants
  • type PeerCredConn
  • type PeerCredListener
    • func New(ctx context.Context, addr string) (*PeerCredListener, error)
    • func (pcl *PeerCredListener) Accept() (net.Conn, error)
    • func (pcl *PeerCredListener) AcceptPeerCred() (*PeerCredConn, error)

Package files

listener.go

Constants

const ErrAddrInUse = unix.EADDRINUSE

ErrAddrInUse is a convenience wrapper around the Posix errno value for EADDRINUSE. Deprecated: Use package toolman.org/net/peercred instead.

type PeerCredConn

type PeerCredConn struct {
    Ucred *unix.Ucred
    net.Conn
}

PeerCredConn is a net.Conn containing the process credentials for the client side of a Unix domain socket connection.

Deprecated: Use package toolman.org/net/peercred instead.

type PeerCredListener

type PeerCredListener struct {
    net.Listener
}

PeerCredListener is an implementation of net.Listener that extracts the identity (i.e. pid, uid, gid) from the connection's client process. This information is then made available through the Ucred member of the *PeerCredConn returned by AcceptPeerCred or Accept (after a type assertion).

Deprecated: Use package toolman.org/net/peercred instead.

func New

func New(ctx context.Context, addr string) (*PeerCredListener, error)

New returns a new PeerCredListener listening on the Unix domain socket addr.

Deprecated: Use package toolman.org/net/peercred instead.

func (*PeerCredListener) Accept

func (pcl *PeerCredListener) Accept() (net.Conn, error)

Accept is a convenience wrapper around AcceptPeerCred allowing PeerCredListener callers that utilize net.Listener to function as expected. The returned net.Conn is a *PeerCredConn which may be accessed through a type assertion. See AcceptPeerCred for details on possible error conditions.

Accept contributes to implementing the net.Listener interface.

Deprecated: Use package toolman.org/net/peercred instead.

func (*PeerCredListener) AcceptPeerCred

func (pcl *PeerCredListener) AcceptPeerCred() (*PeerCredConn, error)

AcceptPeerCred accepts a connection from the receiver's listener returning a *PeerCredConn containing the process credentials for the client. If the underlying Accept fails or if process credentials cannot be extracted, AcceptPeerCred returns nil and an error.

Deprecated: Use package toolman.org/net/peercred instead.