File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,17 @@ public async Task ConnectAsync(CancellationToken cancellationToken = default)
8888 ? errorPacket . ErrorMessage
8989 : "Authentication failed" ;
9090 throw new InvalidOperationException ( $ "MySQL authentication failed: { errorMsg } (Error { errorPacket . ErrorCode } )") ;
91+ case EOFPacket eofPacket :
92+ // EOF packet received, check if it indicates success
93+ if ( ( eofPacket . StatusFlags & 0x0002 ) != 0 )
94+ {
95+ IsAuthenticated = true ;
96+ break ;
97+ }
98+ else
99+ {
100+ throw new InvalidOperationException ( "Authentication failed: EOF packet received without success status. Length: " + eofPacket . Length ) ;
101+ }
91102 default :
92103 throw new InvalidOperationException ( $ "Unexpected packet received during authentication: { authResult ? . GetType ( ) . Name ?? "null" } ") ;
93104 }
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ static MySQLPacketFactory()
1515 ClientInstance = new MySQLPacketFactory ( )
1616 . RegisterPacketType < HandshakePacket > ( - 1 )
1717 . RegisterPacketType < OKPacket > ( 0x00 )
18- . RegisterPacketType < ErrorPacket > ( 0xFF ) ;
18+ . RegisterPacketType < ErrorPacket > ( 0xFF )
19+ . RegisterPacketType < EOFPacket > ( 0xFE ) ;
1920 }
2021
2122 private readonly Dictionary < int , Func < MySQLPacket > > _packetCreators = new ( ) ;
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Buffers ;
3+ using SuperSocket . ProtoBase ;
4+
5+ namespace SuperSocket . MySQL . Packets
6+ {
7+ public class EOFPacket : MySQLPacket , IPacketWithHeaderByte
8+ {
9+ public byte Header { get ; set ; } = 0xFE ;
10+ public ushort WarningCount { get ; set ; }
11+ public ushort StatusFlags { get ; set ; }
12+
13+ public int Length { get ; private set ; }
14+
15+ protected internal override void Decode ( ref SequenceReader < byte > reader , object context )
16+ {
17+ Length = ( int ) reader . Remaining ;
18+
19+ if ( ! reader . TryReadLittleEndian ( out ushort warningCount ) )
20+ throw new InvalidOperationException ( "Failed to read WarningCount from EOFPacket." ) ;
21+
22+ WarningCount = warningCount ;
23+
24+ if ( ! reader . TryReadLittleEndian ( out ushort statusFlags ) )
25+ throw new InvalidOperationException ( "Failed to read StatusFlags from EOFPacket." ) ;
26+
27+ StatusFlags = statusFlags ;
28+ }
29+
30+ protected internal override int Encode ( IBufferWriter < byte > writer )
31+ {
32+ throw new NotImplementedException ( ) ;
33+ }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments