@@ -223,8 +223,9 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
223223 Debug ("Got handshake" )
224224
225225 serverAddress := handshake .ServerAddress
226+ nextState := mcproto .State (handshake .NextState )
226227
227- c .findAndConnectBackend (ctx , frontendConn , clientAddr , inspectionBuffer , serverAddress )
228+ c .findAndConnectBackend (ctx , frontendConn , clientAddr , inspectionBuffer , serverAddress , nextState )
228229 } else if packet .PacketID == mcproto .PacketIdLegacyServerListPing {
229230 handshake , ok := packet .Data .(* mcproto.LegacyServerListPing )
230231 if ! ok {
@@ -243,7 +244,7 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
243244
244245 serverAddress := handshake .ServerAddress
245246
246- c .findAndConnectBackend (ctx , frontendConn , clientAddr , inspectionBuffer , serverAddress )
247+ c .findAndConnectBackend (ctx , frontendConn , clientAddr , inspectionBuffer , serverAddress , mcproto . StateStatus )
247248 } else {
248249 logrus .
249250 WithField ("client" , clientAddr ).
@@ -255,10 +256,10 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
255256}
256257
257258func (c * Connector ) findAndConnectBackend (ctx context.Context , frontendConn net.Conn ,
258- clientAddr net.Addr , preReadContent io.Reader , serverAddress string ) {
259+ clientAddr net.Addr , preReadContent io.Reader , serverAddress string , nextState mcproto. State ) {
259260
260261 backendHostPort , resolvedHost , waker := Routes .FindBackendForServerAddress (ctx , serverAddress )
261- if waker != nil {
262+ if waker != nil && nextState > mcproto . StateStatus {
262263 if err := waker (ctx ); err != nil {
263264 logrus .WithFields (logrus.Fields {"serverAddress" : serverAddress }).WithError (err ).Error ("failed to wake up backend" )
264265 c .metrics .Errors .With ("type" , "wakeup_failed" ).Add (1 )
0 commit comments