|
@@ -7,6 +7,7 @@ import (
|
|
|
"math/rand"
|
|
|
"qfw/util/redis"
|
|
|
"service/config"
|
|
|
+ "strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
)
|
|
@@ -15,12 +16,14 @@ var VarLSCPool = &LSCPool{
|
|
|
JobQueue: make(chan string, config.Sysconfig.JobNum),
|
|
|
WorkerNum: config.Sysconfig.WorkerNum,
|
|
|
Lock: &sync.Mutex{},
|
|
|
+ Randoms: "",
|
|
|
}
|
|
|
|
|
|
type LSCPool struct {
|
|
|
JobQueue chan string //待取的口令
|
|
|
WorkerNum int //当前工作的协程数
|
|
|
- Lock *sync.Mutex
|
|
|
+ Lock *sync.Mutex //口令锁
|
|
|
+ Randoms string //口令集合
|
|
|
}
|
|
|
|
|
|
func (this *LSCPool) GetJob() string {
|
|
@@ -47,6 +50,10 @@ func (this *LSCPool) GetRandom() string {
|
|
|
//如果使用过了 重新获取
|
|
|
for {
|
|
|
LSC := this.SpecialChar(0) + this.LetterRandom(8)
|
|
|
+ if strings.Contains(this.Randoms, LSC) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.Randoms += LSC + "|"
|
|
|
ok, _ := redis.Exists("other", "DIS_"+LSC)
|
|
|
if ok {
|
|
|
continue
|