1. 把tunnelid函数放到其他地方
2.在创建tunnel的时候显示每个tunnel属于哪个model 3.增加了queuecache的测试
This commit is contained in:
23
utils/tunnelid.go
Normal file
23
utils/tunnelid.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
var seed int32
|
||||
|
||||
func init() {
|
||||
seed = 0
|
||||
}
|
||||
|
||||
func TunnelID() string {
|
||||
nowString := time.Now().String() + strconv.Itoa(int(seed))
|
||||
atomic.AddInt32(&seed, 1) //避免多线程情况下获得的种子相同
|
||||
md5Byte := md5.Sum(bytes.NewBufferString(nowString).Bytes())
|
||||
return hex.EncodeToString(md5Byte[:])
|
||||
}
|
||||
Reference in New Issue
Block a user