ptcp

package
v0.0.0-...-14ead05 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONNECTING = iota
	CONNECTED
	CLOSING
	CLOSED
)
View Source
const (
	RETRYTIME     = 5
	RETRYINTERVAL = 500
)

Variables

View Source
var BUFFERSIZE = 65535
View Source
var CHANBUFFERSIZE = 1024
View Source
var CONNCHANBUFSIZE = 1024
View Source
var CONNTIMEOUT = 60
View Source
var LISTENERBUFSIZE = 1024
View Source
var RAWBUFSIZE = 65535

Functions

func Dial

func Dial(proto string, remoteAddr string) (net.Conn, error)

func GetLocalAddr

func GetLocalAddr(remoteAddr string) (net.Addr, error)

func Init

func Init(interfaceName string)

func Listen

func Listen(proto, addr string) (net.Listener, error)

Types

type Addr

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

func NewAddr

func NewAddr(addr string) *Addr

func (*Addr) Network

func (a *Addr) Network() string

func (*Addr) String

func (a *Addr) String() string

type Conn

type Conn struct {
	InputChan  chan string
	OutputChan chan string
	State      int
	LastUpdate time.Time
	// contains filtered or unexported fields
}

func NewConn

func NewConn(localAddr string, remoteAddr string, state int) *Conn

func (*Conn) Close

func (conn *Conn) Close() error

func (*Conn) CloseRequest

func (conn *Conn) CloseRequest() (err error)

func (*Conn) CloseResponse

func (conn *Conn) CloseResponse() (err error)

func (*Conn) IsTimeout

func (conn *Conn) IsTimeout() bool

func (*Conn) LocalAddr

func (conn *Conn) LocalAddr() net.Addr

func (*Conn) Read

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

Block

func (*Conn) ReadWithHeader

func (conn *Conn) ReadWithHeader(b []byte) (n int, err error)

NoBlock

func (*Conn) RemoteAddr

func (conn *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (conn *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (conn *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (conn *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) UpdateTime

func (conn *Conn) UpdateTime()

func (*Conn) Write

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

Block

func (*Conn) WriteWithHeader

func (conn *Conn) WriteWithHeader(b []byte) (n int, err error)

NoBlock

type Listener

type Listener struct {
	Address    string
	InputChan  chan string
	OutputChan chan string
	// contains filtered or unexported fields
}

func NewListener

func NewListener(addr string) (*Listener, error)

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

type PTCP

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

func NewPTCP

func NewPTCP(interfaceName string) (*PTCP, error)

func (*PTCP) CleanTimeoutConns

func (p *PTCP) CleanTimeoutConns()

func (*PTCP) CloseConn

func (p *PTCP) CloseConn(key string)

func (*PTCP) CloseListener

func (p *PTCP) CloseListener(key string)

func (*PTCP) CreateConn

func (p *PTCP) CreateConn(localAddr string, remoteAddr string, conn *Conn)

func (*PTCP) CreateListener

func (p *PTCP) CreateListener(key string, listener *Listener)

func (*PTCP) Start

func (p *PTCP) Start()

type Raw

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

func NewRaw

func NewRaw(interfaceName string) (*Raw, error)

func (*Raw) Read

func (r *Raw) Read() ([]byte, error)

func (*Raw) Write

func (r *Raw) Write(data []byte) error

Jump to

Keyboard shortcuts

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