mirror of
https://github.com/lwch/natpass.git
synced 2026-10-21 03:38:41 +00:00
修正握手数据包中的from_idx字段设置问题
This commit is contained in:
@@ -126,10 +126,6 @@ func (conn *Conn) loopRead(cancel context.CancelFunc) {
|
||||
}
|
||||
}
|
||||
|
||||
func loopWrite(conn *network.Conn, msg *network.Msg, timeout time.Duration) error {
|
||||
return conn.WriteMessage(msg, timeout)
|
||||
}
|
||||
|
||||
func (conn *Conn) loopWrite(cancel context.CancelFunc) {
|
||||
defer conn.Close()
|
||||
defer cancel()
|
||||
@@ -140,7 +136,7 @@ func (conn *Conn) loopWrite(cancel context.CancelFunc) {
|
||||
}
|
||||
msg.From = conn.parent.cfg.ID
|
||||
msg.FromIdx = conn.Idx
|
||||
err := loopWrite(conn.conn, msg, conn.parent.cfg.WriteTimeout)
|
||||
err := conn.conn.WriteMessage(msg, conn.parent.cfg.WriteTimeout)
|
||||
if err != nil {
|
||||
logging.Error("write message error on %s-%d: %v",
|
||||
conn.parent.cfg.ID, conn.Idx, err)
|
||||
|
||||
@@ -58,6 +58,7 @@ func (p *Pool) Get(id ...string) *Conn {
|
||||
return conn
|
||||
}
|
||||
|
||||
p.idx++
|
||||
conn := p.connect(p.idx)
|
||||
if conn == nil {
|
||||
return nil
|
||||
@@ -66,7 +67,6 @@ func (p *Pool) Get(id ...string) *Conn {
|
||||
|
||||
p.Lock()
|
||||
p.conns[c.Idx] = c
|
||||
p.idx++
|
||||
p.Unlock()
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user