mirror of
https://github.com/itzg/mc-router.git
synced 2024-11-24 11:55:24 +01:00
misc: re-enable handshake deadline
This commit is contained in:
parent
4c99daafa3
commit
a86eb65ca5
@ -21,12 +21,22 @@ type IConnector interface {
|
|||||||
StartAcceptingConnections(ctx context.Context, listenAddress string, connRateLimit int) error
|
StartAcceptingConnections(ctx context.Context, listenAddress string, connRateLimit int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
var Connector IConnector = &connectorImpl{
|
type ConnectorMetrics struct {
|
||||||
state: mcproto.StateHandshaking,
|
BytesTransmitted metrics.Counter
|
||||||
|
Connections metrics.Counter
|
||||||
|
ActiveConnections metrics.Gauge
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConnector(metrics *ConnectorMetrics) Connector {
|
||||||
|
|
||||||
|
return &connectorImpl{
|
||||||
|
metrics: metrics,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type connectorImpl struct {
|
type connectorImpl struct {
|
||||||
state mcproto.State
|
state mcproto.State
|
||||||
|
metrics *ConnectorMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connectorImpl) StartAcceptingConnections(ctx context.Context, listenAddress string, connRateLimit int) error {
|
func (c *connectorImpl) StartAcceptingConnections(ctx context.Context, listenAddress string, connRateLimit int) error {
|
||||||
@ -79,14 +89,14 @@ func (c *connectorImpl) HandleConnection(ctx context.Context, frontendConn net.C
|
|||||||
|
|
||||||
inspectionReader := io.TeeReader(frontendConn, inspectionBuffer)
|
inspectionReader := io.TeeReader(frontendConn, inspectionBuffer)
|
||||||
|
|
||||||
/* if err := frontendConn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil {
|
if err := frontendConn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil {
|
||||||
logrus.
|
logrus.
|
||||||
WithError(err).
|
WithError(err).
|
||||||
WithField("client", clientAddr).
|
WithField("client", clientAddr).
|
||||||
Error("Failed to set read deadline")
|
Error("Failed to set read deadline")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
*/packet, err := mcproto.ReadPacket(inspectionReader, clientAddr, c.state)
|
packet, err := mcproto.ReadPacket(inspectionReader, clientAddr, c.state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).WithField("clientAddr", clientAddr).Error("Failed to read packet")
|
logrus.WithError(err).WithField("clientAddr", clientAddr).Error("Failed to read packet")
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user