Resume the app token exchanger (#2209)

This commit is contained in:
ノエルの犬 2023-06-17 02:27:14 +08:00 committed by GitHub
parent e382c6d691
commit c3339de184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 13 deletions

View File

@ -149,8 +149,7 @@ public class GameSession implements GameSessionManager.KcpChannel {
@Override
public void handleReceive(byte[] bytes) {
// Decrypt and turn back into a packet
if (this.getState() != SessionState.WAITING_FOR_TOKEN)
Crypto.xor(bytes, useSecretKey() ? Crypto.ENCRYPT_KEY : Crypto.DISPATCH_KEY);
Crypto.xor(bytes, useSecretKey() ? Crypto.ENCRYPT_KEY : Crypto.DISPATCH_KEY);
ByteBuf packet = Unpooled.wrappedBuffer(bytes);
// Log

View File

@ -92,13 +92,15 @@ public final class RegionHandler implements Router {
// Create a region info object.
var regionInfo =
RegionInfo.newBuilder()
.setGateserverIp(region.Ip)
.setGateserverPort(region.Port)
.setSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
.build();
RegionInfo.newBuilder()
.setGateserverIp(region.Ip)
.setGateserverPort(region.Port)
.build();
// Create an updated region query.
var updatedQuery = QueryCurrRegionHttpRsp.newBuilder().setRegionInfo(regionInfo).build();
var updatedQuery = QueryCurrRegionHttpRsp.newBuilder()
.setRegionInfo(regionInfo)
.setClientSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
.build();
regions.put(
region.Name,
new RegionData(

View File

@ -13,7 +13,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
super(PacketOpcodes.GetPlayerTokenRsp, true);
this.setUseDispatchKey(true);
this.shouldEncrypt = false;
GetPlayerTokenRsp p =
GetPlayerTokenRsp.newBuilder()
@ -39,7 +38,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
super(PacketOpcodes.GetPlayerTokenRsp, true);
this.setUseDispatchKey(true);
this.shouldEncrypt = false;
GetPlayerTokenRsp p =
GetPlayerTokenRsp.newBuilder()
@ -61,7 +59,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
super(PacketOpcodes.GetPlayerTokenRsp, true);
this.setUseDispatchKey(true);
this.shouldEncrypt = false;
GetPlayerTokenRsp p =
GetPlayerTokenRsp.newBuilder()

View File

@ -35,12 +35,12 @@ public class PacketPlayerLoginRsp extends BasePacket {
RegionInfo.newBuilder()
.setGateserverIp(lr(GAME_INFO.accessAddress, GAME_INFO.bindAddress))
.setGateserverPort(lr(GAME_INFO.accessPort, GAME_INFO.bindPort))
.setSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
.build();
regionCache =
var regionCache =
QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp.newBuilder()
.setRegionInfo(serverRegion)
.setClientSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
.build();
} catch (Exception e) {
Grasscutter.getLogger().error("Error while initializing region cache!", e);