securesocket

package
v0.0.0-...-90268b9 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Provides leaky buffer, based on the example in Effective Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCipherMethod

func CheckCipherMethod(method string) error

func Pipe

func Pipe(src io.Reader, dst io.Writer)

func Sort

func Sort(arr []uint64, comparison func(uint64, uint64) int64) []uint64

Types

type Cipher

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

func NewCipher

func NewCipher(method, password string) (c *Cipher, err error)

NewCipher creates a cipher that can be used in Dial() etc. Use cipher.Copy() to create a new cipher with the same method and password to avoid the cost of repeated cipher initialization.

func (*Cipher) Copy

func (c *Cipher) Copy() *Cipher

Copy creates a new cipher at it's initial state.

type Conn

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

func NewConn

func NewConn(c net.Conn, cipher *Cipher) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

type DecOrEnc

type DecOrEnc int
const (
	Decrypt DecOrEnc = iota
	Encrypt
)

type LeakyBuf

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

func NewLeakyBuf

func NewLeakyBuf(n, bufSize int) *LeakyBuf

NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.

func (*LeakyBuf) Get

func (lb *LeakyBuf) Get() (b []byte)

Get returns a buffer from the leaky buffer or create a new buffer.

func (*LeakyBuf) Put

func (lb *LeakyBuf) Put(b []byte)

Put add the buffer into the free buffer pool for reuse. Panic if the buffer size is not the same with the leaky buffer's. This is intended to expose error usage of leaky buffer.

type PacketConn

type PacketConn struct {
	net.PacketConn
	*Cipher
	// contains filtered or unexported fields
}

func NewPacketConn

func NewPacketConn(c net.PacketConn, cipher *Cipher) *PacketConn

func (*PacketConn) Close

func (c *PacketConn) Close() error

func (*PacketConn) ReadFrom

func (c *PacketConn) ReadFrom(b []byte) (n int, src net.Addr, err error)

func (*PacketConn) WriteTo

func (c *PacketConn) WriteTo(b []byte, dst net.Addr) (n int, err error)

type PacketStreamConn

type PacketStreamConn struct {
	net.Conn
}

func NewPacketStreamConn

func NewPacketStreamConn(c net.Conn) *PacketStreamConn

func (*PacketStreamConn) Read

func (c *PacketStreamConn) Read(b []byte) (n int, err error)

func (*PacketStreamConn) Write

func (c *PacketStreamConn) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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