tunnel

package
v0.0.0-...-281afc1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

date : 2015-08-31 author: xjdrew

Index

Constants

View Source
const (
	TaaTokenSize     int = aes.BlockSize
	TaaSignatureSize int = md5.Size
	TaaBlockSize     int = TaaTokenSize + TaaSignatureSize
)
View Source
const (
	LINK_DATA uint8 = iota
	LINK_CREATE
	LINK_CLOSE
	LINK_CLOSE_RECV
	LINK_CLOSE_SEND
	TUN_HEARTBEAT
)
View Source
const (
	TunnelMaxId           = ^uint16(0)
	TunnelMaxTimeout      = 3600
	TunnelPacketSize      = 8192
	TunnelKeepAlivePeriod = time.Second * 180
)

Variables

View Source
var (
	Timeout  int  = 0
	LogLevel uint = 1
	Udt      bool = false
)

Functions

func Debug

func Debug(format string, a ...interface{})

func Error

func Error(format string, a ...interface{})

func Info

func Info(format string, a ...interface{})

func Log

func Log(format string, a ...interface{})

func LogCurStack

func LogCurStack(format string, a ...interface{})

func LogStack

func LogStack(format string, a ...interface{})

func Panic

func Panic(format string, a ...interface{})

func Recover

func Recover()

func Trace

func Trace(format string, a ...interface{})

Types

type Buffer

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

func NewBuffer

func NewBuffer(sz int) *Buffer

func (*Buffer) Close

func (b *Buffer) Close() bool

func (*Buffer) Len

func (b *Buffer) Len() int

func (*Buffer) Pop

func (b *Buffer) Pop() ([]byte, bool)

func (*Buffer) Put

func (b *Buffer) Put(data []byte) bool

type Client

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

tunnel client

func NewClient

func NewClient(listen, backend, secret string, tunnels uint) (*Client, error)

func (*Client) Start

func (cli *Client) Start() error

func (*Client) Status

func (cli *Client) Status()

type ClientHub

type ClientHub struct {
	*Hub
	// contains filtered or unexported fields
}

client hub

type Cmd

type Cmd struct {
	Cmd uint8  // control command
	Id  uint16 // id
}

type Hub

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

func (*Hub) Close

func (h *Hub) Close()

func (*Hub) Send

func (h *Hub) Send(id uint16, data []byte) bool

func (*Hub) SendCmd

func (h *Hub) SendCmd(id uint16, cmd uint8) bool

func (*Hub) Start

func (h *Hub) Start()

func (*Hub) Status

func (h *Hub) Status()

type HubItem

type HubItem struct {
	*ClientHub
	// contains filtered or unexported fields
}

func (*HubItem) Status

func (h *HubItem) Status()

type HubQueue

type HubQueue []*HubItem

func (HubQueue) Len

func (cq HubQueue) Len() int

func (HubQueue) Less

func (cq HubQueue) Less(i, j int) bool

func (*HubQueue) Pop

func (cq *HubQueue) Pop() interface{}

func (*HubQueue) Push

func (cq *HubQueue) Push(x interface{})

func (HubQueue) Swap

func (cq HubQueue) Swap(i, j int)

type IdAllocator

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

func (*IdAllocator) Acquire

func (alloc *IdAllocator) Acquire() uint16

func (*IdAllocator) Release

func (alloc *IdAllocator) Release(id uint16)

type MPool

type MPool struct {
	*sync.Pool
	// contains filtered or unexported fields
}

func NewMPool

func NewMPool(sz int) *MPool

func (*MPool) Get

func (p *MPool) Get() []byte

func (*MPool) Put

func (p *MPool) Put(x []byte)

type Server

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

tunnel server

func NewServer

func NewServer(listen, backend, secret string) (*Server, error)

create a tunnel server

func (*Server) Start

func (s *Server) Start() error

func (*Server) Status

func (s *Server) Status()

type ServerHub

type ServerHub struct {
	*Hub
	// contains filtered or unexported fields
}

server hub

type Taa

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

gotunnel auth algorithm

func NewTaa

func NewTaa(key string) *Taa

func (*Taa) CheckSignature

func (a *Taa) CheckSignature(src []byte) bool

func (*Taa) ExchangeCipherBlock

func (a *Taa) ExchangeCipherBlock(src []byte) ([]byte, bool)

exchange cipher block

func (*Taa) GenCipherBlock

func (a *Taa) GenCipherBlock(token *authToken) []byte

generate cipher block

func (*Taa) GenToken

func (a *Taa) GenToken()

generate new token

func (*Taa) GetRc4key

func (a *Taa) GetRc4key() []byte

func (*Taa) VerifyCipherBlock

func (a *Taa) VerifyCipherBlock(src []byte) bool

verify cipher block

type TcpListener

type TcpListener struct {
	*net.TCPListener
}

func (*TcpListener) Accept

func (l *TcpListener) Accept() (net.Conn, error)

type Tunnel

type Tunnel struct {
	*TunnelConn
	// contains filtered or unexported fields
}

func (*Tunnel) ReadPacket

func (tun *Tunnel) ReadPacket() (linkid uint16, data []byte, err error)

can't read concurrently

func (Tunnel) String

func (tun Tunnel) String() string

func (*Tunnel) WritePacket

func (tun *Tunnel) WritePacket(linkid uint16, data []byte) (err error)

can write concurrently

type TunnelConn

type TunnelConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*TunnelConn) Flush

func (conn *TunnelConn) Flush() error

func (*TunnelConn) Read

func (conn *TunnelConn) Read(b []byte) (int, error)

func (*TunnelConn) SetCipherKey

func (conn *TunnelConn) SetCipherKey(key []byte)

func (*TunnelConn) Write

func (conn *TunnelConn) Write(b []byte) (int, error)

type UdtListener

type UdtListener struct {
	net.Listener
}

func (*UdtListener) Accept

func (l *UdtListener) Accept() (net.Conn, error)

Jump to

Keyboard shortcuts

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