|
|
@ -2,6 +2,7 @@ package tcp
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"io"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
|
|
|
|
v2net "v2ray.com/core/common/net"
|
|
|
|
v2net "v2ray.com/core/common/net"
|
|
|
@ -54,13 +55,19 @@ func (server *Server) handleConnection(conn net.Conn) {
|
|
|
|
conn.Write(server.SendFirst)
|
|
|
|
conn.Write(server.SendFirst)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
request := make([]byte, 4096)
|
|
|
|
request := make([]byte, 4096)
|
|
|
|
for true {
|
|
|
|
for {
|
|
|
|
nBytes, err := conn.Read(request)
|
|
|
|
nBytes, err := conn.Read(request)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
if err != io.EOF {
|
|
|
|
|
|
|
|
fmt.Println("Failed to read request:", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response := server.MsgProcessor(request[:nBytes])
|
|
|
|
response := server.MsgProcessor(request[:nBytes])
|
|
|
|
conn.Write(response)
|
|
|
|
if _, err := conn.Write(response); err != nil {
|
|
|
|
|
|
|
|
fmt.Println("Failed to write response:", err)
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
conn.Close()
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|