1. 把tunnelid函数放到其他地方

2.在创建tunnel的时候显示每个tunnel属于哪个model
3.增加了queuecache的测试
This commit is contained in:
dmy@lab
2016-01-11 00:00:30 +08:00
parent 421c18687e
commit b284b401dc
6 changed files with 90 additions and 48 deletions

23
utils/tunnelid.go Normal file
View 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[:])
}