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
+16 -8
View File
@@ -12,10 +12,12 @@ import (
api2 "github.com/admin-else/strom/mc/api"
"github.com/admin-else/strom/mc/crypto"
"github.com/admin-else/strom/mc/data"
"github.com/admin-else/strom/mc/event"
"github.com/admin-else/strom/mc/proto"
"github.com/admin-else/strom/mc/proto_base"
"github.com/admin-else/strom/mc/proto_generated/v1_21_8"
"github.com/admin-else/strom/mc/proto_generated/v26_2"
"github.com/google/uuid"
)
@@ -183,11 +185,20 @@ func (l *LoginServer) FinishLogin() (err error) {
if l.Given == nil {
l.Given = &l.Requested
}
err = l.Send(&v1_21_8.LoginToClientPacketSuccess{
Uuid: l.Given.UUID,
Username: l.Given.Name,
Properties: nil,
})
if l.ProtocolVersion >= data.MustLookupProtocolVersion("26.2") {
err = l.Send(&v26_2.LoginToClientPacketSuccess{
Uuid: l.Given.UUID,
Username: l.Given.Name,
Properties: nil,
SessionId: uuid.New(),
})
} else {
err = l.Send(&v1_21_8.LoginToClientPacketSuccess{
Uuid: l.Given.UUID,
Username: l.Given.Name,
Properties: nil,
})
}
return
}
@@ -195,9 +206,6 @@ type LoginServerSetting func(*LoginServer)
func WithOtherAccount(a *api2.Account) LoginServerSetting {
return func(s *LoginServer) {
if s.Given == nil {
return
}
s.Given = &NameAndUUID{
Name: a.Name,
UUID: a.Uuid,