mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 21:09:31 +08:00
Resume the app token exchanger (#2209)
This commit is contained in:
parent
e382c6d691
commit
c3339de184
@ -149,8 +149,7 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
|||||||
@Override
|
@Override
|
||||||
public void handleReceive(byte[] bytes) {
|
public void handleReceive(byte[] bytes) {
|
||||||
// Decrypt and turn back into a packet
|
// 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);
|
ByteBuf packet = Unpooled.wrappedBuffer(bytes);
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
|
@ -92,13 +92,15 @@ public final class RegionHandler implements Router {
|
|||||||
|
|
||||||
// Create a region info object.
|
// Create a region info object.
|
||||||
var regionInfo =
|
var regionInfo =
|
||||||
RegionInfo.newBuilder()
|
RegionInfo.newBuilder()
|
||||||
.setGateserverIp(region.Ip)
|
.setGateserverIp(region.Ip)
|
||||||
.setGateserverPort(region.Port)
|
.setGateserverPort(region.Port)
|
||||||
.setSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
|
.build();
|
||||||
.build();
|
|
||||||
// Create an updated region query.
|
// 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(
|
regions.put(
|
||||||
region.Name,
|
region.Name,
|
||||||
new RegionData(
|
new RegionData(
|
||||||
|
@ -13,7 +13,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
|
|||||||
super(PacketOpcodes.GetPlayerTokenRsp, true);
|
super(PacketOpcodes.GetPlayerTokenRsp, true);
|
||||||
|
|
||||||
this.setUseDispatchKey(true);
|
this.setUseDispatchKey(true);
|
||||||
this.shouldEncrypt = false;
|
|
||||||
|
|
||||||
GetPlayerTokenRsp p =
|
GetPlayerTokenRsp p =
|
||||||
GetPlayerTokenRsp.newBuilder()
|
GetPlayerTokenRsp.newBuilder()
|
||||||
@ -39,7 +38,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
|
|||||||
super(PacketOpcodes.GetPlayerTokenRsp, true);
|
super(PacketOpcodes.GetPlayerTokenRsp, true);
|
||||||
|
|
||||||
this.setUseDispatchKey(true);
|
this.setUseDispatchKey(true);
|
||||||
this.shouldEncrypt = false;
|
|
||||||
|
|
||||||
GetPlayerTokenRsp p =
|
GetPlayerTokenRsp p =
|
||||||
GetPlayerTokenRsp.newBuilder()
|
GetPlayerTokenRsp.newBuilder()
|
||||||
@ -61,7 +59,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
|
|||||||
super(PacketOpcodes.GetPlayerTokenRsp, true);
|
super(PacketOpcodes.GetPlayerTokenRsp, true);
|
||||||
|
|
||||||
this.setUseDispatchKey(true);
|
this.setUseDispatchKey(true);
|
||||||
this.shouldEncrypt = false;
|
|
||||||
|
|
||||||
GetPlayerTokenRsp p =
|
GetPlayerTokenRsp p =
|
||||||
GetPlayerTokenRsp.newBuilder()
|
GetPlayerTokenRsp.newBuilder()
|
||||||
|
@ -35,12 +35,12 @@ public class PacketPlayerLoginRsp extends BasePacket {
|
|||||||
RegionInfo.newBuilder()
|
RegionInfo.newBuilder()
|
||||||
.setGateserverIp(lr(GAME_INFO.accessAddress, GAME_INFO.bindAddress))
|
.setGateserverIp(lr(GAME_INFO.accessAddress, GAME_INFO.bindAddress))
|
||||||
.setGateserverPort(lr(GAME_INFO.accessPort, GAME_INFO.bindPort))
|
.setGateserverPort(lr(GAME_INFO.accessPort, GAME_INFO.bindPort))
|
||||||
.setSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
regionCache =
|
var regionCache =
|
||||||
QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp.newBuilder()
|
QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp.newBuilder()
|
||||||
.setRegionInfo(serverRegion)
|
.setRegionInfo(serverRegion)
|
||||||
|
.setClientSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
|
||||||
.build();
|
.build();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().error("Error while initializing region cache!", e);
|
Grasscutter.getLogger().error("Error while initializing region cache!", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user