pkg

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultKeyPath = "./key"

Variables

View Source
var (
	ErrVersion   = errors.New("Invalid vp version error")
	ErrCmd       = errors.New("Invalid vp cmd error")
	ErrHandshake = errors.New("Invalid vp handshake error")
	ErrHandudp   = errors.New("Invalid vp Handudp error")

	ErrEncrypt = errors.New("Invalid vp Encrypt error")
)

Functions

func GenChacha20Key

func GenChacha20Key() ([]byte, error)

func Join

func Join(c1 io.ReadWriteCloser, c2 io.ReadWriteCloser) (inCount int64, outCount int64)

Join two connections together and return the number of bytes transferred

func KeyByteToString

func KeyByteToString(key []byte) string

func KeyStringToByte

func KeyStringToByte(key string) ([]byte, error)

func WriteKeyToFile

func WriteKeyToFile(keyPath string, clientID string, key string) error

Types

type Chacha20Stream

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

func NewChacha20Stream

func NewChacha20Stream(key []byte, conn VeilConn) (*Chacha20Stream, error)

func (*Chacha20Stream) Close

func (s *Chacha20Stream) Close() error

func (*Chacha20Stream) Read

func (s *Chacha20Stream) Read(p []byte) (int, error)

func (*Chacha20Stream) SetWriteDeadline

func (s *Chacha20Stream) SetWriteDeadline(t time.Time) error

func (*Chacha20Stream) Write

func (s *Chacha20Stream) Write(p []byte) (int, error)

type EncryptProtocl

type EncryptProtocl []byte

func (EncryptProtocl) Check

func (ep EncryptProtocl) Check(reader io.Reader) (bool, error)

func (EncryptProtocl) Encode

func (ep EncryptProtocl) Encode(envOn bool) []byte

type HandshakeReq

type HandshakeReq struct {
	ClientID string
}

func (*HandshakeReq) Decode

func (req *HandshakeReq) Decode(reader io.Reader) error

func (*HandshakeReq) Encode

func (req *HandshakeReq) Encode() ([]byte, error)

type UDPpacket

type UDPpacket []byte

func (*UDPpacket) Decode

func (pkt *UDPpacket) Decode(reader io.Reader) error

func (UDPpacket) Encode

func (pkt UDPpacket) Encode() ([]byte, error)

type VeilConn

type VeilConn interface {
	Read(p []byte) (int, error)
	Write(p []byte) (int, error)
	Close() error
	SetWriteDeadline(t time.Time) error
}

type VeilinkProtocol

type VeilinkProtocol struct {
	ClientID         string // 客户端ID
	PublicProtocol   string // 外网协议
	PublicIP         string // 外网IP
	PublicPort       uint16 // 外网端口
	InternalProtocol string // 内网协议
	InternalIP       string // 内网IP
	InternalPort     uint16 // 内网端口
}

VeilinkProtocol Veilink协议

func (*VeilinkProtocol) Decode

func (vp *VeilinkProtocol) Decode(reader io.Reader) error

func (*VeilinkProtocol) Encode

func (vp *VeilinkProtocol) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

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