tcpraw

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 20 Imported by: 0

README

tcpraw

GoDoc Build Status Go Report Card Coverage Statusd MIT licensed

Introduction

A packet-oriented connection by simulating TCP protocol

Features

  1. Tiny
  2. Support IPv4 and IPv6.
  3. Realistic sliding window, NAT friendly.
  4. Pure golang without cgo, available on all architecture.

Documentation

For complete documentation, see the associated Godoc.

Benchmark

goos: linux
goarch: amd64
pkg: github.com/xtaci/tcpraw
BenchmarkEcho-2   	   20000	     93036 ns/op	  11.01 MB/s	    6200 B/op	      62 allocs/op
PASS
ok  	github.com/xtaci/tcpraw	2.758s

Status

Stable

Who is using this

https://github.com/xtaci/kcptun

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BatchSize int = 4
View Source
var (
	ErrFlowNotFound = errors.New("flow not found") // Duration to define expiration time for flows
)
View Source
var MaxPayloadSize int = 52048 // 2048 //如果对方不会发送大报文,建议设置为2048

Functions

func IPTablesReset

func IPTablesReset()

func SetBPFFilterPort

func SetBPFFilterPort(conn *net.IPConn, port uint32) error

Types

type FingerPrintType

type FingerPrintType int
const (
	TypeLinux FingerPrintType = iota
)

type TCPConn

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

TCPConn

func Dial

func Dial(network, address string) (*TCPConn, error)

func Listen

func Listen(network, address string) (*TCPConn, error)

Listen acts like net.ListenTCP, and returns a single packet-oriented connection

func (TCPConn) Close

func (conn TCPConn) Close() error

Close closes the connection.

func (TCPConn) LocalAddr

func (conn TCPConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (TCPConn) ReadFrom

func (conn TCPConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

ReadFrom implements the PacketConn ReadFrom method.

func (TCPConn) ReadFromv2 added in v0.1.2

func (conn TCPConn) ReadFromv2() ([]byte, net.Addr, error)

相比ReadFrom, ReadFromv2优点是少一次copy, 直接返回数据切片,缺点是没有实现接口 PacketConn ReadFrom method.

func (TCPConn) RemoteAddr

func (conn TCPConn) RemoteAddr() net.Addr

add by mo: 只有client 才会返回remote addr

func (TCPConn) SetDSCP

func (conn TCPConn) SetDSCP(dscp int) error

SetDSCP sets the 6bit DSCP field in IPv4 header, or 8bit Traffic Class in IPv6 header.

func (TCPConn) SetDeadline

func (conn TCPConn) SetDeadline(t time.Time) error

SetDeadline implements the Conn SetDeadline method.

func (TCPConn) SetReadBuffer

func (conn TCPConn) SetReadBuffer(bytes int) error

SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.

func (TCPConn) SetReadDeadline

func (conn TCPConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (TCPConn) SetWriteBuffer

func (conn TCPConn) SetWriteBuffer(bytes int) error

SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.

func (TCPConn) SetWriteDeadline

func (conn TCPConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (TCPConn) WriteTo

func (conn TCPConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

WriteTo implements the PacketConn WriteTo method.

Directories

Path Synopsis
example/client command
example/server command
fecv2
package kcp
package kcp

Jump to

Keyboard shortcuts

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