conncapture

package module
v0.0.0-...-704b431 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

conncapture is a hack to allow a grpc Client or Server to retrieve the net.Conn they are currently operating over.

Normally, this is a terrible idea. There is at least one use case in which it makes sense:

  • Sending file descriptors over unix file sockets

In order to accomplish net.Conn capture, a credentials.TransportCredentials wrapper is provided by conncapture.TransportCredentials(cred credentials.TransportCredentials) to wrap your real TLS or other TransportCredentials (or nil if you have none).

The result is that the peer.Addr will be a wrapped version of the actual net.Conn that meets the net.Addr interface. This can be retrieved in servers with peer.FromContext(ctx) or in clients with grpc.Peer(p *peer.Peer).

Documentation

Overview

Package conncapture provides a credentials.TransportCredential wrapper that allows capturing the net.Conn as the peer.Addr which can be accessed by the server using peer.FromContext or the client using grpc.PeerCallOption. Be very careful in its use, as *most* things you might do with it *will* screwup your grpc. There is at least one case (sending of file descriptors over unix file sockets out of band) in which it is useful.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnToAddrInfo

func ConnToAddrInfo(conn net.Conn) net.Conn

ConnToAddrInfo wraps conn so as to also meet the net.Addr interface

func FromContext

func FromContext(ctx context.Context) (net.Conn, bool)

FromContext - retrieve net.Conn from context. Only works inside a 'server' and only works when used in conjunction with conncapture.TransportCredentials(...)

func TransportCredentials

TransportCredentials wraps cred (which may be nil) such that peer.Addr *is* the net.Conn and can be access by the server using peer.FromContext or the client using grpc.PeerCallOption

Types

This section is empty.

Jump to

Keyboard shortcuts

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