<file_sep>// Copyright 2019 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

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

import (
	"context"
	"net"

	"toolman.org/net/peercred"
)

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

// 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.
type PeerCredListener peercred.Listener

// New returns a new PeerCredListener listening on the Unix domain socket addr.
// Deprecated: Use package toolman.org/net/peercred instead.
func New(ctx context.Context, addr string) (*PeerCredListener, error) {
	lis, err := peercred.Listen(ctx, addr)
	return (*PeerCredListener)(lis), err
}

// 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 (pcl *PeerCredListener) Accept() (net.Conn, error) {
	return (*peercred.Listener)(pcl).Accept()
}

// 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.
func (pcl *PeerCredListener) AcceptPeerCred() (*PeerCredConn, error) {
	conn, err := (*peercred.Listener)(pcl).AcceptPeerCred()
	return (*PeerCredConn)(conn), err
}

// 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 PeerCredConn peercred.Conn
<file_sep>module toolman.org/net/peercredlistener

go 1.12

require toolman.org/net/peercred v0.4.0
<file_sep>
# peercredlistener 

`import "toolman.org/net/peercredlistener"`

* [Overview](#pkg-overview)
* [Index](#pkg-index)
* [Subdirectories](#pkg-subdirectories)


## <a name="pkg-overview">Overview</a>
Package peercredlistener is deprecated in favor of toolman.org/net/peercred.


## <a name="pkg-index">Index</a>
* [Constants](#pkg-constants)
* [type PeerCredConn](#PeerCredConn)
* [type PeerCredListener](#PeerCredListener)
  * [func New(ctx context.Context, addr string) (*PeerCredListener, error)](#New)
  * [func (pcl *PeerCredListener) Accept() (net.Conn, error)](#PeerCredListener.Accept)
  * [func (pcl *PeerCredListener) AcceptPeerCred() (*PeerCredConn, error)](#PeerCredListener.AcceptPeerCred)


#### <a name="pkg-files">Package files</a>
[listener.go](/src/toolman.org/net/peercredlistener/listener.go) 


## <a name="pkg-constants">Constants</a>
``` go
const ErrAddrInUse = unix.EADDRINUSE
```
ErrAddrInUse is a convenience wrapper around the Posix errno value for EADDRINUSE.
Deprecated: Use package toolman.org/net/peercred instead.


## <a name="PeerCredConn">type</a> [PeerCredConn](/src/target/listener.go?s=4734:4791#L138)
``` go
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.


## <a name="PeerCredListener">type</a> [PeerCredListener](/src/target/listener.go?s=2919:2965#L71)
``` go
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.


### <a name="New">func</a> [New](/src/target/listener.go?s=3047:3116#L76)
``` go
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.


### <a name="PeerCredListener.Accept">func</a> (\*PeerCredListener) [Accept](/src/target/listener.go?s=3657:3712#L93)
``` go
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.

### <a name="PeerCredListener.AcceptPeerCred">func</a> (\*PeerCredListener) [AcceptPeerCred](/src/target/listener.go?s=4020:4088#L101)
``` go
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.
<file_sep>
# pclcreds
`import "toolman.org/net/peercredlistener/pclcreds"`

* [Install](#pkg-install)
* [Overview](#pkg-overview)
* [Index](#pkg-index)

## <a name="pkg-install">Install</a>

```sh
    go get toolman.org/net/peercredlistener/pclcreds
```

## <a name="pkg-overview">Overview</a>
Package pclcreds is deprecated in favor of toolman.org/net/peercred/grpcpeer.


## <a name="pkg-index">Index</a>
* [Variables](#pkg-variables)
* [func FromContext(ctx context.Context) (*unix.Ucred, error)](#FromContext)
* [func TransportCredentials() grpc.ServerOption](#TransportCredentials)


#### <a name="pkg-files">Package files</a>
[creds.go](/src/toolman.org/net/peercredlistener/pclcreds/creds.go) 


## <a name="pkg-variables">Variables</a>
``` go
var ErrNoCredentials = grpcpeer.ErrNoCredentials
```
ErrNoCredentials is returned by FromContext if the provided Context
contains no peer process credentials.

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


``` go
var ErrNoPeer = grpcpeer.ErrNoPeer
```
ErrNoPeer is returned by FromContext if the provided Context contains
no gRPC peer.

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


## <a name="FromContext">func</a> [FromContext](/src/target/creds.go?s=5662:5720#L141)
``` go
func FromContext(ctx context.Context) (*unix.Ucred, error)
```
FromContext extracts peer process credentials, if any, from the given
Context. If the Context has no gRPC peer, ErrNoPeer is returned. If the
Context's peer is of the wrong type (i.e. contains no peer process
credentials), ErrNoCredentials will be returned.

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

## <a name="TransportCredentials">func</a> [TransportCredentials](/src/target/creds.go?s=3701:3746#L89)
``` go
func TransportCredentials() grpc.ServerOption
```
TransportCredentials returns a grpc.ServerOption that exposes the peer
process credentials (i.e. pid, uid, gid) extracted by a PeerCredListener.
The peer credentials are available by passing a server method's Context
to the FromContext function.

Deprecated: Use package toolman.org/net/peercred/grpcpeer instead.
<file_sep>module toolman.org/net/peercredlistener/pclcreds

go 1.12

require (
	golang.org/x/sys v0.0.0-20190526052359-791d8a0f4d09
	google.golang.org/grpc v1.21.0
	toolman.org/net/peercred/grpcpeer v0.4.0
)
<file_sep>// Copyright 2019 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

// Package pclcreds is deprecated in favor of toolman.org/net/peercred/grpcpeer.
package pclcreds

import (
	"context"

	"golang.org/x/sys/unix"
	"google.golang.org/grpc"

	"toolman.org/net/peercred/grpcpeer"
)

// ErrNoPeer is returned by FromContext if the provided Context contains
// no gRPC peer.
// Deprecated: Use package toolman.org/net/peercred/grpcpeer instead.
var ErrNoPeer = grpcpeer.ErrNoPeer

// ErrNoCredentials is returned by FromContext if the provided Context
// contains no peer process credentials.
// Deprecated: Use package toolman.org/net/peercred/grpcpeer instead.
var ErrNoCredentials = grpcpeer.ErrNoCredentials

// TransportCredentials returns a grpc.ServerOption that exposes the peer
// process credentials (i.e. pid, uid, gid) extracted by a PeerCredListener.
// The peer credentials are available by passing a server method's Context
// to the FromContext function.
// Deprecated: Use package toolman.org/net/peercred/grpcpeer instead.
func TransportCredentials() grpc.ServerOption { return grpcpeer.TransportCredentials() }

// FromContext extracts peer process credentials, if any, from the given
// Context. If the Context has no gRPC peer, ErrNoPeer is returned. If the
// Context's peer is of the wrong type (i.e. contains no peer process
// credentials), ErrNoCredentials will be returned.
// Deprecated: Use package toolman.org/net/peercred/grpcpeer instead.
func FromContext(ctx context.Context) (*unix.Ucred, error) { return grpcpeer.FromContext(ctx) }
