Back to

Package tunnel

v0.0.0 (9513d3d)
Latest Go to latest
Published: Jul 4, 2019 | License: MIT | Module:


Package Files


const (
	Left direction = iota


func PutTunnel

func PutTunnel(tunnel *Tunnel)

PutTunnel 将*Tunnel放回TunnelPool

type Option

type Option func(*Tunnel)

Option 选项

func WithLeft

func WithLeft(left net.Conn) Option

WithLeft 带有左连接

func WithLeftCipher

func WithLeftCipher(c mycipher.Cipher) Option

WithLeftCipher 带有左连接的Cipher

func WithRight

func WithRight(right net.Conn) Option

WithRight 带有右连接

func WithRightCipher

func WithRightCipher(c mycipher.Cipher) Option

WithRightCipher 带有右连接的Cipher

func WithSpeedLimiter

func WithSpeedLimiter(l ratelimit.Limiter) Option

WithSpeedLimiter 带有速度限制器

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 带有超时长度

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields

Tunnel 是一个全双工的双向隧道,内置加密解密、暂停等待的控制器

func NewTunnel

func NewTunnel(opts ...Option) *Tunnel

NewTunnel 构建新的Tunnel

func (*Tunnel) Clear

func (t *Tunnel) Clear()

Clear 清空Tunnel

func (*Tunnel) Close

func (t *Tunnel) Close()

Close 关闭Tunnel,关闭前会停止其双向的流动

func (*Tunnel) Closed

func (t *Tunnel) Closed() bool

Closed Tunnel是否已经关闭

func (*Tunnel) Flow

func (t *Tunnel) Flow()

Flow 开始双向流动 此方法阻塞 同一个Tunnel同时只能执行一次Flow,多次Flow会导致panic

func (*Tunnel) IsNil

func (t *Tunnel) IsNil() bool

IsNil Tunnel的Left和Right都为nil

func (*Tunnel) Left

func (t *Tunnel) Left() net.Conn

Left 左边的连接

func (*Tunnel) ReadLeft

func (t *Tunnel) ReadLeft(buffer []byte) (int, error)

ReadLeft 从左边读取数据

func (*Tunnel) ReadLeftStr

func (t *Tunnel) ReadLeftStr() (text string, err error)

ReadLeftStr 从左边读字符串

func (*Tunnel) ReadRight

func (t *Tunnel) ReadRight(buffer []byte) (int, error)

ReadRight 从右边读取数据

func (*Tunnel) ReadRightStr

func (t *Tunnel) ReadRightStr() (text string, err error)

ReadRightStr 从左边读字符串

func (*Tunnel) Right

func (t *Tunnel) Right() net.Conn

Right 右边的连接

func (*Tunnel) Update

func (t *Tunnel) Update(opts ...Option) *Tunnel

Update 更新Tunnel的属性

func (*Tunnel) WriteLeft

func (t *Tunnel) WriteLeft(buffer []byte) (int, error)

WriteLeft 向左边写数据

func (*Tunnel) WriteRight

func (t *Tunnel) WriteRight(buffer []byte) (int, error)

WriteRight 向右边写数据

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier