|
|
@@ -124,7 +124,7 @@ func Server(cf *config.Config, bind string, path string, hash string, fn conn.Se
|
|
|
cf: cf,
|
|
|
conn: conn,
|
|
|
cipher: cipher,
|
|
|
- remoteIp: net.ParseIP(remoteIp),
|
|
|
+ remoteIp: util.StrToIP(remoteIp),
|
|
|
}
|
|
|
fn(ws)
|
|
|
})
|
|
|
@@ -316,8 +316,10 @@ func (c *Ws2) ReadMessage(deadline int) (msgType conn.MsgType, id uint16, cmd st
|
|
|
|
|
|
// 获取远程的地址
|
|
|
func (c *Ws2) RemoteIP() net.IP {
|
|
|
- return c.remoteIp
|
|
|
- // return util.AddrToIP(c.conn.RemoteAddr())
|
|
|
+ if c.remoteIp != nil {
|
|
|
+ return c.remoteIp
|
|
|
+ }
|
|
|
+ return util.AddrToIP(c.conn.RemoteAddr())
|
|
|
}
|
|
|
|
|
|
// 获取本地的地址
|