gsecureconn

package
v0.0.0-...-047dcd9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePassword

func ParsePassword(passwordString string) (*password, error)

解析采用base64编码的字符串获取密码

func RandPassword

func RandPassword() string

产生 256个byte随机组合的 密码,最后会使用base64编码为字符串存储在配置文件中 不能出现任何一个重复的byte位,必须又 0-255 组成,并且都需要包含

func WrapConn

func WrapConn(rawConn net.Conn, cipher *Cipher) (net.Conn, error)

see net.DialTCP

func WrapListener

func WrapListener(lis net.Listener, cipher *Cipher) net.Listener

Types

type Cipher

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

func NewCipher

func NewCipher(encodePassword *password) *Cipher

新建一个编码解码器

func (*Cipher) Decode

func (cipher *Cipher) Decode(bs []byte)

解码加密后的数据到原数据

func (*Cipher) Encode

func (cipher *Cipher) Encode(bs []byte)

加密原数据

type Listener

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

func (*Listener) Accept

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

see net.ListenTCP

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

type SecureConn

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

const (

bufSize = 1024

)

var bpool sync.Pool

func init() {
	bpool.New = func() interface{} {
		return make([]byte, bufSize)
	}
}
func bufferPoolGet() []byte {
	return bpool.Get().([]byte)
}
func bufferPoolPut(b []byte) {
	bpool.Put(b)
}

加密传输的 Socket

func (*SecureConn) Close

func (c *SecureConn) Close() error

func (*SecureConn) LocalAddr

func (c *SecureConn) LocalAddr() net.Addr

func (*SecureConn) Read

func (c *SecureConn) Read(b []byte) (n int, err error)

从输入流里读取加密过的数据,解密后把原数据放到bs里

func (*SecureConn) RemoteAddr

func (c *SecureConn) RemoteAddr() net.Addr

func (*SecureConn) SetDeadline

func (c *SecureConn) SetDeadline(t time.Time) error

func (*SecureConn) SetReadDeadline

func (c *SecureConn) SetReadDeadline(t time.Time) error

func (*SecureConn) SetWriteDeadline

func (c *SecureConn) SetWriteDeadline(t time.Time) error

func (*SecureConn) Write

func (c *SecureConn) Write(b []byte) (int, error)

把放在bs里的数据加密后立即全部写入输出流

Jump to

Keyboard shortcuts

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