1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00
This commit is contained in:
LXY1226 2020-08-03 06:47:06 +08:00
commit aac35885a1
2 changed files with 7 additions and 3 deletions

View File

@ -40,6 +40,7 @@ type QQClient struct {
decoders map[string]func(*QQClient, uint16, []byte) (interface{}, error) decoders map[string]func(*QQClient, uint16, []byte) (interface{}, error)
handlers sync.Map handlers sync.Map
server *net.TCPAddr
syncCookie []byte syncCookie []byte
pubAccountCookie []byte pubAccountCookie []byte
@ -616,7 +617,10 @@ var servers = []*net.TCPAddr{
} }
func (c *QQClient) connect() error { func (c *QQClient) connect() error {
conn, err := net.DialTCP("tcp", nil, servers[rand.Intn(len(servers))]) if c.server == nil {
c.server = servers[rand.Intn(len(servers))]
}
conn, err := net.DialTCP("tcp", nil, c.server)
if err != nil { if err != nil {
return err return err
} }

View File

@ -40,7 +40,7 @@ func NewTTList(ttl int64) *TTList {
func (l *TTList) Add(i interface{}) { func (l *TTList) Add(i interface{}) {
l.lock.Lock() l.lock.Lock()
l.lock.Unlock() defer l.lock.Unlock()
l.list = append(l.list, &item{ l.list = append(l.list, &item{
i: i, i: i,
lastAccess: time.Now().Unix(), lastAccess: time.Now().Unix(),
@ -49,7 +49,7 @@ func (l *TTList) Add(i interface{}) {
func (l *TTList) Any(filter func(i interface{}) bool) bool { func (l *TTList) Any(filter func(i interface{}) bool) bool {
l.lock.Lock() l.lock.Lock()
l.lock.Unlock() defer l.lock.Unlock()
for _, it := range l.list { for _, it := range l.list {
if filter(it.i) { if filter(it.i) {
it.lastAccess = time.Now().Unix() it.lastAccess = time.Now().Unix()