util

package
v0.0.0-...-2a177de Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheHttpBodyAdd

func CacheHttpBodyAdd(obj string, key string, value []byte) (err error)

func CacheHttpBodyGet

func CacheHttpBodyGet(obj string, key string) (err error, value interface{})

func CacheHttpHeadAdd

func CacheHttpHeadAdd(obj string, key string, head *http.Header) (err error)

func CacheHttpHeadGet

func CacheHttpHeadGet(obj string, key string) (err error, head http.Header, n int64)

func CacheHttpObjExist

func CacheHttpObjExist(obj string) bool

func CacheTcpAdd

func CacheTcpAdd(obj string, key string, value []byte) (err error)

func CacheTcpGet

func CacheTcpGet(obj string, key string) (err error, value interface{})

func CacheTcpObjExist

func CacheTcpObjExist(obj string) bool

func CreateToken

func CreateToken(id uint64, second int64, data []byte, secret, name string) string

func Decrypt

func Decrypt(ciphertext []byte, privatekey *rsa.PrivateKey) (decryptedtext []byte, err error)

decrypt

func DecryptByBytes

func DecryptByBytes(ciphertext, privatekey []byte) (decryptedtext []byte, err error)

func DecryptPkcs

func DecryptPkcs(ciphertext []byte, privatekey *rsa.PrivateKey) (decryptedtext []byte, err error)

decrypt

func DecryptPkcsByBytes

func DecryptPkcsByBytes(ciphertext, privatekey []byte) (decryptedtext []byte, err error)

func DumpPrivateKeyBytes

func DumpPrivateKeyBytes(privatekey *rsa.PrivateKey) (err error, b []byte)

func DumpPrivateKeyFile

func DumpPrivateKeyFile(privatekey *rsa.PrivateKey, filename string) error

func DumpPublicKeyBytes

func DumpPublicKeyBytes(publickey *rsa.PublicKey) (err error, b []byte)

func DumpPublicKeyFile

func DumpPublicKeyFile(publickey *rsa.PublicKey, filename string) error

func Encrypt

func Encrypt(plaintext []byte, publickey *rsa.PublicKey) (ciphertext []byte, err error)

encrypt

func EncryptPkcs

func EncryptPkcs(plaintext []byte, publickey *rsa.PublicKey) (ciphertext []byte, err error)

encrypt

func GenerateKey

func GenerateKey(bit int) (*rsa.PrivateKey, error)

func HttpConnLimitAdd

func HttpConnLimitAdd(obj string, count int64) (err error)

func InitCache

func InitCache(obj, cacheExpirationCleanTime string, defaultExpiration time.Duration, maxCacheSize int64)

func InitQueue

func InitQueue()

func LoadPrivateKeyBase64

func LoadPrivateKeyBase64(base64key string) (*rsa.PrivateKey, error)

Load private key from base64

func LoadPrivateKeyBytes

func LoadPrivateKeyBytes(b []byte) (*rsa.PrivateKey, error)

func LoadPrivateKeyFile

func LoadPrivateKeyFile(keyfile string) (*rsa.PrivateKey, error)

Load private key from private key file

func LoadPublicKeyBase64

func LoadPublicKeyBase64(base64key string) (*rsa.PublicKey, error)

func LoadPublicKeyBytes

func LoadPublicKeyBytes(b []byte) (*rsa.PublicKey, error)

func LoadPublicKeyFile

func LoadPublicKeyFile(keyfile string) (*rsa.PublicKey, error)

func QueueAddHandle

func QueueAddHandle(cmd uint32, handlerQueue HandlerQueueFunc)

func QueueSend

func QueueSend(subj string, b []byte, version, cmd uint32) (err error)

func RateAdd

func RateAdd(obj string, n, conn int64) (err error)

func RateHttpAdd

func RateHttpAdd(obj string, rsp *http.Response, n int64) (err error)

func RateLimitInit

func RateLimitInit(obj string, maxRate, maxRatePer, maxConn, per int64) (err error)

func TcpConnLimitAdd

func TcpConnLimitAdd(obj string, count int64) (err error)

func ToMd5

func ToMd5(uid uint64, expireToken int64, secret string) (decode []byte)

Types

type Claims

type Claims struct {
	Uid  uint64           `json:"uid,omitempty"`
	Name string           `json:"name,omitempty"`
	Data *json.RawMessage `json:"data,omitempty"`
	jwt.StandardClaims
}

func TokenAuth

func TokenAuth(signedToken, secret string) (claims *Claims, err error)

type HandlerQueueFunc

type HandlerQueueFunc func(b []byte)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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