Documentation ¶
Index ¶
- Constants
- Variables
- func Log(conn TunnelConn, isRelay bool)
- func NewAccessLog(ctx context.Context) error
- func RegisterTunnel(name string, tunnel Tunnel)
- type Address
- type AddressType
- type Client
- type Command
- type Config
- type Conn
- type ConnDialer
- type ConnListener
- type Dialer
- type Listener
- type Logger
- type Metadata
- type PacketConn
- type PacketDialer
- type PacketListener
- type Server
- type Tunnel
- type TunnelConn
- type Tunnels
Constants ¶
const Name = "TUNNEL"
Variables ¶
var EmptyMetadata = Metadata{ Command: Empty, Address: &Address{ DomainName: "-", AddressType: InvalidType, }, }
Functions ¶
func Log ¶
func Log(conn TunnelConn, isRelay bool)
func NewAccessLog ¶
func RegisterTunnel ¶
RegisterTunnel register a tunnel by tunnel name
Types ¶
type Address ¶
type Address struct { DomainName string Port int NetworkType string net.IP AddressType SrcAddress *Address }
func NewAddressFromBytes ¶
func NewAddressFromHostPort ¶
type AddressType ¶
type AddressType byte
const ( IPv4 AddressType = 1 DomainName AddressType = 3 IPv6 AddressType = 4 InvalidType AddressType = 0 )
func (AddressType) String ¶
func (a AddressType) String() string
type Conn ¶
type Conn interface { net.Conn Name() string Metadata() *Metadata User() statistic.User Tunnels() *Tunnels Epoch() time.Time Sent() uint64 Recv() uint64 }
Conn is the TCP connection in the tunnel
type ConnDialer ¶
ConnDialer creates TCP connections from the tunnel
type ConnListener ¶
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 PacketConn ¶
type PacketConn interface { net.PacketConn Name() string WriteWithMetadata([]byte, *Metadata) (int, error) ReadWithMetadata([]byte) (int, *Metadata, error) User() statistic.User Tunnels() *Tunnels Epoch() time.Time Sent() uint64 Recv() uint64 }
PacketConn is the UDP packet stream in the tunnel
type PacketDialer ¶
type PacketDialer interface {
DialPacket(statistic.User, 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 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
type TunnelConn ¶
type Tunnels ¶
type Tunnels struct {
// contains filtered or unexported fields
}
func NewTunnels ¶
func NewTunnels() *Tunnels
func (*Tunnels) Append ¶
func (pts *Tunnels) Append(conn TunnelConn) *Tunnels
func (*Tunnels) Get ¶
func (ts *Tunnels) Get(name string) TunnelConn
func (*Tunnels) Root ¶
func (ts *Tunnels) Root() TunnelConn