tunnel

package
v0.0.0-...-daa1c5c Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTunnel

func RegisterTunnel(name string, tunnel Tunnel)

RegisterTunnel register a tunnel by tunnel name

Types

type Address

type Address struct {
	DomainName  string
	Port        int
	NetworkType string
	net.IP
	AddressType
}

func NewAddressFromAddr

func NewAddressFromAddr(network, addr string) (*Address, error)

func NewAddressFromHostPort

func NewAddressFromHostPort(network string, host string, port int) *Address

func (*Address) Network

func (a *Address) Network() string

func (*Address) ReadFrom

func (a *Address) ReadFrom(r io.Reader) error

func (*Address) ResolveIP

func (a *Address) ResolveIP() (net.IP, error)

func (*Address) String

func (a *Address) String() string

func (*Address) WriteTo

func (a *Address) WriteTo(w io.Writer) error

type AddressType

type AddressType byte
const (
	IPv4       AddressType = 1
	DomainName AddressType = 3
	IPv6       AddressType = 4
)

type Client

type Client interface {
	Dialer
	io.Closer
}

Client is the tunnel client based on stream connections

type Command

type Command byte

type Conn

type Conn interface {
	net.Conn
	Metadata() *Metadata
}

Conn is the TCP connection in the tunnel

type ConnDialer

type ConnDialer interface {
	DialConn(*Address, Tunnel) (Conn, error)
}

ConnDialer creates TCP connections from the tunnel

type ConnListener

type ConnListener interface {
	AcceptConn(Tunnel) (Conn, error)
}

ConnListener accept TCP connections

type Dialer

type Dialer interface {
	ConnDialer
	PacketDialer
}

Dialer can dial to original server with a tunnel

type Listener

type Listener interface {
	ConnListener
	PacketListener
}

Listener can accept TCP and UDP streams from a tunnel

type Metadata

type Metadata struct {
	Command
	*Address
}

func (*Metadata) Network

func (r *Metadata) Network() string

func (*Metadata) ReadFrom

func (r *Metadata) ReadFrom(rr io.Reader) error

func (*Metadata) String

func (r *Metadata) String() string

func (*Metadata) WriteTo

func (r *Metadata) WriteTo(w io.Writer) error

type PacketConn

type PacketConn interface {
	net.PacketConn
	WriteWithMetadata([]byte, *Metadata) (int, error)
	ReadWithMetadata([]byte) (int, *Metadata, error)
}

PacketConn is the UDP packet stream in the tunnel

type PacketDialer

type PacketDialer interface {
	DialPacket(Tunnel) (PacketConn, error)
}

PacketDialer creates UDP packet stream from the tunnel

type PacketListener

type PacketListener interface {
	AcceptPacket(Tunnel) (PacketConn, error)
}

PacketListener accept UDP packet stream We don't have any tunnel based on packet streams, so AcceptPacket will always receive a real PacketConn

type Server

type Server interface {
	Listener
	io.Closer
}

Server is the tunnel server based on stream connections

type Tunnel

type Tunnel interface {
	Name() string
	NewClient(context.Context, Client) (Client, error)
	NewServer(context.Context, Server) (Server, error)
}

Tunnel describes a tunnel, allowing creating a tunnel from another tunnel We assume that the lower tunnels know exatly how upper tunnels work, and lower tunnels is transparent for the upper tunnels

func GetTunnel

func GetTunnel(name string) (Tunnel, error)

Jump to

Keyboard shortcuts

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