mirror of
https://github.com/wonli/aqi.git
synced 2025-12-24 10:40:58 +08:00
IpConnAddr
This commit is contained in:
@@ -26,7 +26,7 @@ func Dispatcher(c *Client, request string) {
|
||||
}
|
||||
|
||||
//请求频率限制5毫秒
|
||||
if t.Sub(c.LastRequestTime).Microseconds() <= 5 {
|
||||
if t.Sub(c.LastRequestTime).Microseconds() <= 2 {
|
||||
c.SendRawMsg(-13, "sys.requestLimit", "Your requests are too frequent", nil)
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -31,6 +32,7 @@ func HttpHandler(w http.ResponseWriter, r *http.Request) {
|
||||
r.Header.Set("Sec-Websocket-Protocol", h.Protocol)
|
||||
}
|
||||
|
||||
ipAddr := ip.GetIPAddress(r)
|
||||
addr, ok := conn.RemoteAddr().(*net.TCPAddr)
|
||||
if !ok {
|
||||
logger.SugarLog.Errorf("获取IP地址错误")
|
||||
@@ -41,8 +43,8 @@ func HttpHandler(w http.ResponseWriter, r *http.Request) {
|
||||
Hub: Hub,
|
||||
Conn: conn,
|
||||
Send: make(chan []byte, 32),
|
||||
IpAddress: ip.GetIPAddress(r),
|
||||
IpConnAddr: addr.String(),
|
||||
IpAddress: ipAddr,
|
||||
IpConnAddr: fmt.Sprintf("%s:%d", ipAddr, addr.Port),
|
||||
ConnectionTime: time.Now(),
|
||||
HttpRequest: r,
|
||||
HttpWriter: w,
|
||||
|
||||
Reference in New Issue
Block a user