mirror of
https://github.com/duanhf2012/origin.git
synced 2026-03-11 10:07:31 +08:00
新增获取客户端ip接口
This commit is contained in:
@@ -71,6 +71,10 @@ func (tcpConn *TCPConn) Close() {
|
|||||||
tcpConn.closeFlag = true
|
tcpConn.closeFlag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tcpConn *TCPConn) GetRemoteIp() string {
|
||||||
|
return tcpConn.conn.RemoteAddr().String()
|
||||||
|
}
|
||||||
|
|
||||||
func (tcpConn *TCPConn) doWrite(b []byte) {
|
func (tcpConn *TCPConn) doWrite(b []byte) {
|
||||||
if len(tcpConn.writeChan) == cap(tcpConn.writeChan) {
|
if len(tcpConn.writeChan) == cap(tcpConn.writeChan) {
|
||||||
log.Debug("close conn: channel full")
|
log.Debug("close conn: channel full")
|
||||||
|
|||||||
@@ -187,3 +187,13 @@ func (slf *TcpService) Close(clientid uint64) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *TcpService) GetClientIp(clientid uint64) string{
|
||||||
|
slf.mapClientLocker.Lock()
|
||||||
|
defer slf.mapClientLocker.Unlock()
|
||||||
|
pClient,ok := slf.mapClient[clientid]
|
||||||
|
if ok == false{
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return pClient.tcpConn.GetRemoteIp()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user