utils

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2015 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialAndProxy

func DialAndProxy(a net.Conn, proto, dest string) error

DialAndProxy takes a net.Conn "a", and a destination "dest" to dial, and forwards traffic between the connections.

func DialAndProxyTLS

func DialAndProxyTLS(a net.Conn, proto, dest string, config *tls.Config) error

DialAndProxyTLS takes a net.Conn "a", and a destination "dest" to dial with TLS, and forwards traffic between the connections.

func GetHints

func GetHints(c net.Conn) []interface{}

GetHints is a convenience function for retrieving hints from a net.Conn if available, otherwise returning nil.

Types

type ChannelListener

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

ChannelListener simulates a net.Listener, with Accept simply waiting on a channel to feed it connections. This is needed, as Go's http library does not provide a way to simply handle a single connection, but only supports accepting the connections itself, but can be used for anything that only accepts a net.Listener.

func NewChannelListener

func NewChannelListener(input chan net.Conn, addr net.Addr) *ChannelListener

NewChannelListener returns a fully iniitalized ChannelListener.

func (*ChannelListener) Accept

func (c *ChannelListener) Accept() (conn net.Conn, err error)

Accept waits on the ChannelListeners channel for new connections.

func (*ChannelListener) Addr

func (c *ChannelListener) Addr() net.Addr

Addr returns the net.Addr of the listener.

func (*ChannelListener) Close

func (c *ChannelListener) Close() error

Close closes the channel.

func (*ChannelListener) Push

func (c *ChannelListener) Push(conn net.Conn)

Push pushes a net.Conn to the ChannelListeners channel.

type HintConn

type HintConn struct {
	net.Conn
	// contains filtered or unexported fields
}

HintConn is a simple net.Conn wrapper implemented HintedConn.

func NewHintConn

func NewHintConn(c net.Conn, hints []interface{}) *HintConn

NewHintConn provides a new *HintConn.

func (*HintConn) Hints

func (h *HintConn) Hints() []interface{}

Hints retrieves the current hints.

type HintedConn

type HintedConn interface {
	net.Conn

	// Hints retrieves the current hints.
	Hints() []interface{}
}

HintedConn describes a net.Conn which also provides hints about transports.

type ProxyConn

type ProxyConn struct {
	net.Conn
	// contains filtered or unexported fields
}

ProxyConn simulates reads for the buffered content. When buffer is empty, it simply behaves like the net.Conn it wraps.

func NewProxyConn

func NewProxyConn(c net.Conn, buffer []byte, storedErr error) *ProxyConn

NewProxyConn returns a fully initialized ProxyConn.

func (*ProxyConn) Hints

func (c *ProxyConn) Hints() []interface{}

Hints return the stored hints.

func (*ProxyConn) Read

func (c *ProxyConn) Read(p []byte) (int, error)

Read reads data from the connection. If buffer is available, it will try to serve the request from the buffer alone. If the buffer is empty, it simply calls read.

func (*ProxyConn) SetHints

func (c *ProxyConn) SetHints(hints []interface{})

SetHints sets the stored hints.

Jump to

Keyboard shortcuts

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