faketcp

package
v0.0.0-...-be1852b Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var CONNCHANBUFSIZE = 1024
View Source
var CONNTIMEOUT = 60
View Source
var LISTENERBUFSIZE = 1024
View Source
var PACKETCONNBUFFERSIZE = 1024

Functions

func Dial

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

func GetLocalAddr

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

Types

type Conn

type Conn struct {
	State int

	LastUpdate time.Time
	// contains filtered or unexported fields
}

func NewConn

func NewConn(internalConn *net.IPConn, localPort int, remoteAddr uint32, remotePort int, state int) *Conn

func (*Conn) Close

func (conn *Conn) Close() error

func (*Conn) CloseRequest

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

func (*Conn) LocalAddr

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

TODO: implement

func (*Conn) Read

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

Block needs upto 40 bytes extra :(

func (*Conn) ReadWithHeader

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

Blocks and Reads

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)

B

type IpPortPair

type IpPortPair struct {
	Addr *net.IPAddr
	Port int
}

type PacketConn

type PacketConn struct {
	TcpSquatter *net.TCPListener
	// fd         int
	InputChan  chan dataAdressPair
	OutputChan chan dataAdressPair
	// contains filtered or unexported fields
}

func ListenPacket

func ListenPacket(proto, addr string) (*PacketConn, error)

func NewPacketConn

func NewPacketConn(localAddr uint32, localPort int, internalConn *net.IPConn, tcpSquatter *net.TCPListener) *PacketConn

func (*PacketConn) Close

func (conn *PacketConn) Close() error

func (*PacketConn) LocalAddr

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

TODO: implement

func (*PacketConn) ReadFrom

func (conn *PacketConn) ReadFrom(b []byte) (n int, addr *IpPortPair, err error)

//Block needs upto 40 bytes extra :(

func (*PacketConn) RemoteAddr

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

func (*PacketConn) SetDeadline

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

func (*PacketConn) SetReadDeadline

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

func (*PacketConn) SetWriteDeadline

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

func (*PacketConn) WriteTo

func (conn *PacketConn) WriteTo(p []byte, addr *IpPortPair) (n int, err error)

Jump to

Keyboard shortcuts

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