mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-29 20:56:30 -05:00
format code
This commit is contained in:
parent
3e2cd914b3
commit
e2bd6abb04
@ -5,7 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/v2ray/v2ray-core"
|
"github.com/v2ray/v2ray-core"
|
||||||
v2io "github.com/v2ray/v2ray-core/common/io"
|
v2io "github.com/v2ray/v2ray-core/common/io"
|
||||||
@ -16,11 +16,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
requestReadTimeOut = 4 * time.Second
|
requestReadTimeOut = 4 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
zeroTime time.Time
|
zeroTime time.Time
|
||||||
)
|
)
|
||||||
|
|
||||||
type VMessInboundHandler struct {
|
type VMessInboundHandler struct {
|
||||||
@ -63,16 +63,16 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
|
|||||||
|
|
||||||
reader := protocol.NewVMessRequestReader(handler.clients)
|
reader := protocol.NewVMessRequestReader(handler.clients)
|
||||||
|
|
||||||
// Timeout 4 seconds to prevent DoS attack
|
// Timeout 4 seconds to prevent DoS attack
|
||||||
connection.SetReadDeadline(time.Now().Add(requestReadTimeOut))
|
connection.SetReadDeadline(time.Now().Add(requestReadTimeOut))
|
||||||
request, err := reader.Read(connection)
|
request, err := reader.Read(connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warning("VMessIn: Invalid request from (%s): %v", connection.RemoteAddr().String(), err)
|
log.Warning("VMessIn: Invalid request from (%s): %v", connection.RemoteAddr().String(), err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debug("VMessIn: Received request for %s", request.Address.String())
|
log.Debug("VMessIn: Received request for %s", request.Address.String())
|
||||||
// Clear read timeout
|
// Clear read timeout
|
||||||
connection.SetReadDeadline(zeroTime)
|
connection.SetReadDeadline(zeroTime)
|
||||||
|
|
||||||
ray := handler.vPoint.NewInboundConnectionAccepted(request.Destination())
|
ray := handler.vPoint.NewInboundConnectionAccepted(request.Destination())
|
||||||
input := ray.InboundInput()
|
input := ray.InboundInput()
|
||||||
|
Loading…
Reference in New Issue
Block a user