Documentation ¶
Index ¶
- func NewEndpoint(dev Device, mtu int) stack.LinkEndpoint
- type Device
- type Endpoint
- type Handler
- type Logger
- type Packet
- type Reader
- type Stack
- func (s *Stack) Add(k int, conn *UDPConn)
- func (s *Stack) Close() error
- func (s *Stack) Del(k int)
- func (s *Stack) Get(k int) (*UDPConn, bool)
- func (s *Stack) HandlePacket(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool
- func (s *Stack) HandleStream(r *tcp.ForwarderRequest)
- func (s *Stack) Start(device Device, handler Handler, logger Logger, mtu int) (err error)
- type TCPConn
- type UDPConn
- func (conn *UDPConn) Close() error
- func (conn *UDPConn) HandlePacket(b []byte, addr *net.UDPAddr)
- func (conn *UDPConn) LocalAddr() net.Addr
- func (conn *UDPConn) ReadTo(b []byte) (n int, addr net.Addr, err error)
- func (conn *UDPConn) RemoteAddr() net.Addr
- func (d *UDPConn) SetDeadline(t time.Time) error
- func (d *UDPConn) SetReadDeadline(t time.Time) error
- func (d *UDPConn) SetWriteDeadline(t time.Time) error
- func (conn *UDPConn) WriteFrom(b []byte, addr net.Addr) (int, error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶
type Device interface { // Reader is ... Reader // Writer is ... Writer // DeviceType is ... // give device type DeviceType() string }
Device is a tun-like device for reading packets from system
type Endpoint ¶
type Endpoint struct { // Endpoint is ... *channel.Endpoint // Reader is ... // read packets from tun device Reader Reader // Writer is ... // write packets to tun device Writer Writer // contains filtered or unexported fields }
Endpoint is ...
func (*Endpoint) Attach ¶
func (e *Endpoint) Attach(dispatcher stack.NetworkDispatcher)
Attach is to attach device to stack
func (*Endpoint) WriteNotify ¶
func (e *Endpoint) WriteNotify()
WriteNotify is to write packets back to system
type Logger ¶
type Logger interface { Error(string, ...interface{}) Info(string, ...interface{}) Debug(string, ...interface{}) }
Logger is for showing logs of netstack
type Packet ¶
type Packet struct { // Addr is ... // target address Addr *net.UDPAddr // Byte is ... // packet payload Byte []byte }
Packet is ...
type Stack ¶
type Stack struct { // Logger is ... Logger // Device is ... // layer 2 device for reading and writing packets Device Device // Handler is ... // handle tcp and udp connections Handler Handler // Stack is ... Stack *stack.Stack // contains filtered or unexported fields }
Stack is ... pure go netstack provided by gvisor.dev
func (*Stack) HandlePacket ¶
func (s *Stack) HandlePacket(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool
HandlePacket is to handle UDP connections
func (*Stack) HandleStream ¶
func (s *Stack) HandleStream(r *tcp.ForwarderRequest)
HandleStream is to handle incoming TCP connections
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn is ...
func NewUDPConn ¶
func NewUDPConn(key int, id stack.TransportEndpointID, pkt *stack.PacketBuffer, s *Stack) *UDPConn
NewUDPConn is to create a new *UDPConn
func (*UDPConn) HandlePacket ¶
HandlePacket is to read packet to UDPConn
func (*UDPConn) RemoteAddr ¶
RemoteAddr is net.PacketConn.RemoteAddr
func (*UDPConn) SetDeadline ¶
SetDeadline implements net.Conn.SetDeadline and net.PacketConn.SetDeadline.
func (*UDPConn) SetReadDeadline ¶
SetReadDeadline implements net.Conn.SetReadDeadline and net.PacketConn.SetReadDeadline.
func (*UDPConn) SetWriteDeadline ¶
SetWriteDeadline implements net.Conn.SetWriteDeadline and net.PacketConn.SetWriteDeadline.