util

package
v0.0.0-...-c605b0d Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckScrambledPassword

func CheckScrambledPassword(salt, hpwd, auth []byte) bool

CheckScrambledPassword check scrambled password received from client. The new authentication is performed in following manner:

SERVER:  public_seed=create_random_string()
         send(public_seed)
CLIENT:  recv(public_seed)
         hash_stage1=sha1("password")
         hash_stage2=sha1(hash_stage1)
         reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
         // this three steps are done in scramble()
         send(reply)
SERVER:  recv(reply)
         hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
         candidate_hash2=sha1(hash_stage1)
         check(candidate_hash2==hash_stage2)
         // this three steps are done in check_scramble()

func DecodePassword

func DecodePassword(pwd string) ([]byte, error)

DecodePassword converts hex string password without prefix '*' to byte array.

func DelKeyWithPrefix

func DelKeyWithPrefix(rm kv.RetrieverMutator, prefix kv.Key) error

DelKeyWithPrefix deletes keys with prefix.

func EncodePassword

func EncodePassword(pwd string) string

EncodePassword converts plaintext password to hashed hex string.

func RowKeyPrefixFilter

func RowKeyPrefixFilter(rowKeyPrefix kv.Key) kv.FnKeyCmp

RowKeyPrefixFilter returns a function which checks whether currentKey has decoded rowKeyPrefix as prefix.

func RunWithRetry

func RunWithRetry(retryCnt int, backoff uint64, f func() (bool, error)) (err error)

RunWithRetry will run the f with backoff and retry. retryCnt: Max retry count backoff: When run f failed, it will sleep backoff * triedCount time.Millisecond. Function f should have two return value. The first one is an bool which indicate if the err if retryable. The second is if the f meet any error.

func ScanMetaWithPrefix

func ScanMetaWithPrefix(retriever kv.Retriever, prefix kv.Key, filter func(kv.Key, []byte) bool) error

ScanMetaWithPrefix scans metadata with the prefix.

func Sha1Hash

func Sha1Hash(bs []byte) []byte

Sha1Hash is an util function to calculate sha1 hash.

func WithCancel

func WithCancel(parent context.Context) (context.Context, context.CancelFunc)

WithCancel is the same as standard WithCancel, but the caller of cancel is traced.

func WithTimeout

func WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

WithTimeout is the same as standard WithCancel, but the caller of cancel is traced.

Types

type ProcessInfo

type ProcessInfo struct {
	ID      uint64
	User    string
	Host    string
	DB      string
	Command string
	Time    time.Time
	State   uint16
	Info    string
}

ProcessInfo is a struct used for show processlist statement.

type SessionManager

type SessionManager interface {
	ShowProcessList() []ProcessInfo
	Kill(connectionID uint64, query bool)
}

SessionManager is an interface for session manage. Show processlist and kill statement rely on this interface.

Directories

Path Synopsis
Package mock is just for test only.
Package mock is just for test only.

Jump to

Keyboard shortcuts

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