Fix 26.2 login_success protocol handling and add convertibility tests

- Server sends v26_2 login_success with SessionId for protocol >= 776

- Client adds v26_2 login_success handler and scopes v1_21_8 handler to <= 26.1

- Fix WithOtherAccount guard in login server

- Add smart-convert assumption tests for login server/client

- Improve translatePacketVersion error messages
This commit is contained in:
adman
2026-07-23 17:00:13 +02:00
parent 94301a4a50
commit b90830881f
6 changed files with 159 additions and 12 deletions
+4 -3
View File
@@ -166,13 +166,14 @@ func (c *Conn) ActivateReceiveRoutine() (chSending <-chan any) {
func (c *Conn) translatePacketVersion(packet proto_base.EncodeDecodeAble, packetInfo proto_base.PacketInfo) (convertedPacket proto_base.EncodeDecodeAble, packetInfoReal proto_base.PacketInfo, err error) {
packetInfoReal, found := LookupPacketInfoByNameProtocolVersionStateAndDirection(packetInfo.Name, c.ProtocolVersion, c.State(), packetInfo.Direction)
if !found {
err = PacketDoesntExistInFutureVersionErr
err = fmt.Errorf("%w: %s from pv%d to pv%d in %s/%s not found", PacketDoesntExistInFutureVersionErr, packetInfo.Name, packetInfo.ProtocolVersion, c.ProtocolVersion, packetInfo.State, packetInfo.Direction)
return
}
dstType := reflect.TypeOf(packetInfoReal.Type)
if !SmartConvertibleTo(reflect.TypeOf(packetInfo.Type), dstType) {
err = CantTranslateErr
srcType := reflect.TypeOf(packetInfo.Type)
if !SmartConvertibleTo(srcType, dstType) {
err = fmt.Errorf("%w: %s from pv%d to pv%d in %s/%s (src=%s dst=%s)", CantTranslateErr, packetInfo.Name, packetInfo.ProtocolVersion, c.ProtocolVersion, packetInfo.State, packetInfo.Direction, srcType, dstType)
return
}
// can't fail cause pacetinfo.type is proto_base.EncodeDecodeAble