1
This commit is contained in:
@@ -144,9 +144,10 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
|
||||
func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
|
||||
if s.discorse {
|
||||
if s.discorse && !conn.Context().(*player.ClientData).IsCrossDomain {
|
||||
handle(conn)
|
||||
}
|
||||
conn.Context().(*player.ClientData).IsCrossDomain = true
|
||||
data, err := s.codec.Decode(conn)
|
||||
if err != nil {
|
||||
if conn.Context().(*player.ClientData).ERROR_CONNUT > 5 {
|
||||
@@ -177,7 +178,6 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
|
||||
func (s *Server) parser(c gnet.Conn, line []byte) {
|
||||
|
||||
c.Context().(*player.ClientData).IsCrossDomain = true
|
||||
//todo 这里待实现注入player实体
|
||||
s.handler.Handle(c, line)
|
||||
}
|
||||
@@ -189,11 +189,7 @@ const CROSS_DOMAIN = "<?xml version=\"1.0\"?><!DOCTYPE cross-domain-policy><cros
|
||||
const TEXT = "<policy-file-request/>\x00"
|
||||
|
||||
func handle(c gnet.Conn) {
|
||||
clientdata := c.Context().(*player.ClientData)
|
||||
if clientdata.IsCrossDomain {
|
||||
return
|
||||
|
||||
}
|
||||
// 读取数据并检查是否为跨域请求
|
||||
data, err := c.Peek(len(TEXT))
|
||||
if err != nil {
|
||||
@@ -207,7 +203,6 @@ func handle(c gnet.Conn) {
|
||||
c.Write([]byte(CROSS_DOMAIN))
|
||||
c.Discard(len(TEXT))
|
||||
|
||||
clientdata.IsCrossDomain = true
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user