h1z1-server 0.20.1-2 → 0.20.2-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/clients/gatewayclient.js +107 -107
- package/src/clients/loginclient.ts +228 -228
- package/src/clients/soeclient.js +321 -321
- package/src/clients/zoneclient.ts +172 -172
- package/src/packets/ClientProtocol/ClientProtocol_1080/abilities.ts +114 -114
- package/src/packets/ClientProtocol/ClientProtocol_1080/ability.ts +38 -38
- package/src/packets/ClientProtocol/ClientProtocol_1080/achievement.ts +62 -62
- package/src/packets/ClientProtocol/ClientProtocol_1080/acquaintance.ts +14 -14
- package/src/packets/ClientProtocol/ClientProtocol_1080/activityManager.ts +17 -17
- package/src/packets/ClientProtocol/ClientProtocol_1080/activityService.ts +18 -18
- package/src/packets/ClientProtocol/ClientProtocol_1080/character.ts +404 -404
- package/src/packets/ClientProtocol/ClientProtocol_1080/chat.ts +57 -57
- package/src/packets/ClientProtocol/ClientProtocol_1080/clientUpdate.ts +341 -341
- package/src/packets/ClientProtocol/ClientProtocol_1080/coinStore.ts +100 -100
- package/src/packets/ClientProtocol/ClientProtocol_1080/collision.ts +31 -31
- package/src/packets/ClientProtocol/ClientProtocol_1080/combat.ts +25 -25
- package/src/packets/ClientProtocol/ClientProtocol_1080/command.ts +636 -636
- package/src/packets/ClientProtocol/ClientProtocol_1080/construction.ts +62 -62
- package/src/packets/ClientProtocol/ClientProtocol_1080/container.ts +97 -97
- package/src/packets/ClientProtocol/ClientProtocol_1080/currency.ts +26 -26
- package/src/packets/ClientProtocol/ClientProtocol_1080/definitionFilter.ts +73 -73
- package/src/packets/ClientProtocol/ClientProtocol_1080/deployable.ts +19 -19
- package/src/packets/ClientProtocol/ClientProtocol_1080/dto.ts +82 -82
- package/src/packets/ClientProtocol/ClientProtocol_1080/effects.ts +176 -176
- package/src/packets/ClientProtocol/ClientProtocol_1080/equipment.ts +125 -125
- package/src/packets/ClientProtocol/ClientProtocol_1080/experience.ts +85 -85
- package/src/packets/ClientProtocol/ClientProtocol_1080/facility.ts +171 -171
- package/src/packets/ClientProtocol/ClientProtocol_1080/friend.ts +100 -100
- package/src/packets/ClientProtocol/ClientProtocol_1080/guild.ts +31 -31
- package/src/packets/ClientProtocol/ClientProtocol_1080/h1z1packets.ts +128 -128
- package/src/packets/ClientProtocol/ClientProtocol_1080/implant.ts +20 -20
- package/src/packets/ClientProtocol/ClientProtocol_1080/inGamePurchase.ts +362 -362
- package/src/packets/ClientProtocol/ClientProtocol_1080/items.ts +88 -88
- package/src/packets/ClientProtocol/ClientProtocol_1080/loadout.ts +88 -88
- package/src/packets/ClientProtocol/ClientProtocol_1080/lobby.ts +24 -24
- package/src/packets/ClientProtocol/ClientProtocol_1080/lobbyGameDefinition.ts +35 -35
- package/src/packets/ClientProtocol/ClientProtocol_1080/loot.ts +14 -14
- package/src/packets/ClientProtocol/ClientProtocol_1080/mapRegion.ts +110 -110
- package/src/packets/ClientProtocol/ClientProtocol_1080/metaGameEvent.ts +23 -23
- package/src/packets/ClientProtocol/ClientProtocol_1080/missions.ts +33 -33
- package/src/packets/ClientProtocol/ClientProtocol_1080/mount.ts +86 -86
- package/src/packets/ClientProtocol/ClientProtocol_1080/operation.ts +25 -25
- package/src/packets/ClientProtocol/ClientProtocol_1080/profileStats.ts +33 -33
- package/src/packets/ClientProtocol/ClientProtocol_1080/quickChat.ts +49 -49
- package/src/packets/ClientProtocol/ClientProtocol_1080/ragdoll.ts +14 -14
- package/src/packets/ClientProtocol/ClientProtocol_1080/recipe.ts +35 -35
- package/src/packets/ClientProtocol/ClientProtocol_1080/referenceData.ts +113 -113
- package/src/packets/ClientProtocol/ClientProtocol_1080/rewardBuffs.ts +20 -20
- package/src/packets/ClientProtocol/ClientProtocol_1080/shared.ts +2388 -2388
- package/src/packets/ClientProtocol/ClientProtocol_1080/skill.ts +37 -37
- package/src/packets/ClientProtocol/ClientProtocol_1080/staticFacilityInfo.ts +41 -41
- package/src/packets/ClientProtocol/ClientProtocol_1080/target.ts +14 -14
- package/src/packets/ClientProtocol/ClientProtocol_1080/ui.ts +37 -37
- package/src/packets/ClientProtocol/ClientProtocol_1080/vehicle.ts +291 -291
- package/src/packets/ClientProtocol/ClientProtocol_1080/voice.ts +41 -41
- package/src/packets/ClientProtocol/ClientProtocol_1080/wallOfData.ts +43 -43
- package/src/packets/ClientProtocol/ClientProtocol_1080/weapon.ts +274 -274
- package/src/packets/ClientProtocol/ClientProtocol_1080/wordFilter.ts +22 -22
- package/src/packets/ClientProtocol/ClientProtocol_1080/zoneSetting.ts +35 -35
- package/src/packets/ClientProtocol/ClientProtocol_860/abilities.ts +207 -207
- package/src/packets/ClientProtocol/ClientProtocol_860/ability.ts +361 -361
- package/src/packets/ClientProtocol/ClientProtocol_860/achievement.ts +62 -62
- package/src/packets/ClientProtocol/ClientProtocol_860/acquaintance.ts +45 -45
- package/src/packets/ClientProtocol/ClientProtocol_860/activityManager.ts +17 -17
- package/src/packets/ClientProtocol/ClientProtocol_860/activityService.ts +18 -18
- package/src/packets/ClientProtocol/ClientProtocol_860/base.ts +2455 -2455
- package/src/packets/ClientProtocol/ClientProtocol_860/chat.ts +63 -63
- package/src/packets/ClientProtocol/ClientProtocol_860/clientPcData.ts +30 -30
- package/src/packets/ClientProtocol/ClientProtocol_860/clientUpdate.ts +434 -434
- package/src/packets/ClientProtocol/ClientProtocol_860/coinStore.ts +100 -100
- package/src/packets/ClientProtocol/ClientProtocol_860/collision.ts +31 -31
- package/src/packets/ClientProtocol/ClientProtocol_860/combat.ts +173 -173
- package/src/packets/ClientProtocol/ClientProtocol_860/command.ts +672 -672
- package/src/packets/ClientProtocol/ClientProtocol_860/construction.ts +42 -42
- package/src/packets/ClientProtocol/ClientProtocol_860/container.ts +30 -30
- package/src/packets/ClientProtocol/ClientProtocol_860/currency.ts +26 -26
- package/src/packets/ClientProtocol/ClientProtocol_860/definitionFilter.ts +73 -73
- package/src/packets/ClientProtocol/ClientProtocol_860/deployable.ts +19 -19
- package/src/packets/ClientProtocol/ClientProtocol_860/dto.ts +73 -73
- package/src/packets/ClientProtocol/ClientProtocol_860/effects.ts +176 -176
- package/src/packets/ClientProtocol/ClientProtocol_860/equipment.ts +112 -112
- package/src/packets/ClientProtocol/ClientProtocol_860/experience.ts +85 -85
- package/src/packets/ClientProtocol/ClientProtocol_860/facility.ts +185 -185
- package/src/packets/ClientProtocol/ClientProtocol_860/friend.ts +100 -100
- package/src/packets/ClientProtocol/ClientProtocol_860/guild.ts +31 -31
- package/src/packets/ClientProtocol/ClientProtocol_860/h1z1packets.ts +134 -134
- package/src/packets/ClientProtocol/ClientProtocol_860/implant.ts +20 -20
- package/src/packets/ClientProtocol/ClientProtocol_860/inGamePurchase.ts +362 -362
- package/src/packets/ClientProtocol/ClientProtocol_860/items.ts +38 -38
- package/src/packets/ClientProtocol/ClientProtocol_860/loadout.ts +110 -110
- package/src/packets/ClientProtocol/ClientProtocol_860/lobby.ts +24 -24
- package/src/packets/ClientProtocol/ClientProtocol_860/lobbyGameDefinition.ts +35 -35
- package/src/packets/ClientProtocol/ClientProtocol_860/loot.ts +34 -34
- package/src/packets/ClientProtocol/ClientProtocol_860/mapRegion.ts +110 -110
- package/src/packets/ClientProtocol/ClientProtocol_860/metaGameEvent.ts +23 -23
- package/src/packets/ClientProtocol/ClientProtocol_860/missions.ts +33 -33
- package/src/packets/ClientProtocol/ClientProtocol_860/mount.ts +125 -125
- package/src/packets/ClientProtocol/ClientProtocol_860/operation.ts +39 -39
- package/src/packets/ClientProtocol/ClientProtocol_860/profileStats.ts +154 -154
- package/src/packets/ClientProtocol/ClientProtocol_860/quickChat.ts +49 -49
- package/src/packets/ClientProtocol/ClientProtocol_860/ragdoll.ts +146 -146
- package/src/packets/ClientProtocol/ClientProtocol_860/recipe.ts +96 -96
- package/src/packets/ClientProtocol/ClientProtocol_860/referenceData.ts +56 -56
- package/src/packets/ClientProtocol/ClientProtocol_860/rewardBuffs.ts +20 -20
- package/src/packets/ClientProtocol/ClientProtocol_860/shared.ts +2183 -2183
- package/src/packets/ClientProtocol/ClientProtocol_860/skill.ts +89 -89
- package/src/packets/ClientProtocol/ClientProtocol_860/staticFacilityInfo.ts +41 -41
- package/src/packets/ClientProtocol/ClientProtocol_860/target.ts +124 -124
- package/src/packets/ClientProtocol/ClientProtocol_860/thrustPad.ts +18 -18
- package/src/packets/ClientProtocol/ClientProtocol_860/ui.ts +83 -83
- package/src/packets/ClientProtocol/ClientProtocol_860/vehicle.ts +411 -411
- package/src/packets/ClientProtocol/ClientProtocol_860/voice.ts +39 -39
- package/src/packets/ClientProtocol/ClientProtocol_860/wallOfData.ts +61 -61
- package/src/packets/ClientProtocol/ClientProtocol_860/warpgate.ts +22 -22
- package/src/packets/ClientProtocol/ClientProtocol_860/weapon.ts +274 -274
- package/src/packets/ClientProtocol/ClientProtocol_860/wordFilter.ts +22 -22
- package/src/packets/ClientProtocol/ClientProtocol_860/zoneSetting.ts +35 -35
- package/src/packets/LoginUdp/LoginUdp_11/loginTunnelPackets.ts +43 -43
- package/src/packets/LoginUdp/LoginUdp_11/loginpackets.ts +471 -471
- package/src/packets/LoginUdp/LoginUdp_9/loginTunnelPackets.ts +43 -43
- package/src/packets/LoginUdp/LoginUdp_9/loginpackets.ts +441 -441
- package/src/packets/gatewaypackets.ts +73 -73
- package/src/packets/packettable.ts +33 -33
- package/src/protocols/gatewayprotocol.ts +122 -122
- package/src/protocols/h1emuprotocol.ts +175 -175
- package/src/protocols/h1z1protocol.ts +675 -675
- package/src/protocols/loginprotocol.ts +139 -139
- package/src/protocols/loginprotocol2016.ts +141 -141
- package/src/servers/GatewayServer/gatewayserver.ts +10 -5
- package/src/servers/H1emuServer/h1emuLoginServer.ts +64 -64
- package/src/servers/H1emuServer/h1emuZoneServer.ts +123 -123
- package/src/servers/H1emuServer/shared/h1emuclient.ts +29 -29
- package/src/servers/H1emuServer/shared/h1emuserver.ts +112 -112
- package/src/servers/LoginServer/loginclient.ts +18 -18
- package/src/servers/LoginServer/loginserver.ts +980 -980
- package/src/servers/LoginServer/workers/httpServer.ts +120 -120
- package/src/servers/SoeServer/soeclient.ts +66 -66
- package/src/servers/SoeServer/soeinputstream.ts +6 -4
- package/src/servers/SoeServer/soeoutputstream.ts +4 -3
- package/src/servers/SoeServer/soeserver.ts +466 -462
- package/src/servers/ZoneServer/classes/character.ts +200 -200
- package/src/servers/ZoneServer/classes/vehicles.ts +115 -115
- package/src/servers/ZoneServer/classes/zoneclient.ts +0 -1
- package/src/servers/ZoneServer/commands/admin.ts +34 -34
- package/src/servers/ZoneServer/commands/dev.ts +255 -255
- package/src/servers/ZoneServer/commands/hax.ts +1088 -1088
- package/src/servers/ZoneServer/workers/createBaseEntities.ts +1203 -1203
- package/src/servers/ZoneServer/workers/dynamicWeather.ts +416 -416
- package/src/servers/ZoneServer/zonepackethandlers.ts +2347 -2347
- package/src/servers/ZoneServer/zoneserver.ts +16 -5
- package/src/servers/ZoneServer2016/classes/character.ts +53 -53
- package/src/servers/ZoneServer2016/classes/vehicle.ts +111 -111
- package/src/servers/ZoneServer2016/classes/worldobjectmanager.ts +1253 -1253
- package/src/servers/ZoneServer2016/commands/admin.ts +104 -104
- package/src/servers/ZoneServer2016/commands/dev.ts +1020 -1020
- package/src/servers/ZoneServer2016/commands/hax.ts +1 -1
- package/src/servers/ZoneServer2016/workers/dynamicWeather.ts +373 -373
- package/src/servers/ZoneServer2016/zonepackethandlers.ts +24 -1
- package/src/servers/ZoneServer2016/zoneserver.ts +11 -8
- package/src/servers/shared/workers/udpServerWorker.ts +68 -68
- package/src/types/gatewayserver.ts +34 -34
- package/src/types/loginserver.ts +78 -78
- package/src/types/packets.ts +2500 -2500
- package/src/types/shared.ts +24 -24
- package/src/types/soeserver.ts +35 -35
- package/src/types/zonedata.ts +27 -27
- package/src/types/zoneserver.ts +641 -641
- package/src/utils/lz4/lz4.ts +253 -253
- package/src/utils/utils.ts +327 -327
package/package.json
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
// ======================================================================
|
|
2
|
-
//
|
|
3
|
-
// GNU GENERAL PUBLIC LICENSE
|
|
4
|
-
// Version 3, 29 June 2007
|
|
5
|
-
// copyright (C) 2020 - 2021 Quentin Gruber
|
|
6
|
-
// copyright (C) 2021 - 2022 H1emu community
|
|
7
|
-
//
|
|
8
|
-
// https://github.com/QuentinGruber/h1z1-server
|
|
9
|
-
// https://www.npmjs.com/package/h1z1-server
|
|
10
|
-
//
|
|
11
|
-
// Based on https://github.com/psemu/soe-network
|
|
12
|
-
// ======================================================================
|
|
13
|
-
|
|
14
|
-
const EventEmitter = require("events").EventEmitter,
|
|
15
|
-
SOEClient = require("./soeclient").SOEClient,
|
|
16
|
-
fs = require("fs"),
|
|
17
|
-
util = require("util"),
|
|
18
|
-
GatewayProtocol = require("../protocols/gatewayprotocol").GatewayProtocol,
|
|
19
|
-
GatewayPackets = require("../protocols/gatewayprotocol").GatewayPackets,
|
|
20
|
-
debug = require("debug")("GatewayClient");
|
|
21
|
-
|
|
22
|
-
function GatewayClientError(message) {
|
|
23
|
-
this.name = this.constructor.name;
|
|
24
|
-
this.message = message;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
util.inherits(GatewayClientError, Error);
|
|
28
|
-
|
|
29
|
-
class GatewayClient {
|
|
30
|
-
constructor(serverAddress, serverPort, key, localPort) {
|
|
31
|
-
EventEmitter.call(this);
|
|
32
|
-
|
|
33
|
-
const soeClient = (this._soeClient = new SOEClient(
|
|
34
|
-
"ExternalGatewayApi_3",
|
|
35
|
-
serverAddress,
|
|
36
|
-
serverPort,
|
|
37
|
-
key,
|
|
38
|
-
localPort
|
|
39
|
-
));
|
|
40
|
-
const protocol = (this._protocol = new GatewayProtocol());
|
|
41
|
-
const me = this;
|
|
42
|
-
|
|
43
|
-
soeClient.on("appdata", function (err, data) {
|
|
44
|
-
const packet = protocol.parse(data);
|
|
45
|
-
const result = packet.result;
|
|
46
|
-
|
|
47
|
-
switch (packet.name) {
|
|
48
|
-
case "LoginReply":
|
|
49
|
-
if (result.loggedIn) {
|
|
50
|
-
me.emit("login", null, result);
|
|
51
|
-
} else {
|
|
52
|
-
me.emit("login", new GatewayClientError("Login failed"));
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
case "TunnelPacketToExternalConnection":
|
|
56
|
-
me.emit("tunneldata", null, packet.tunnelData, packet.flags);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
soeClient.on("connect", function (err, result) {
|
|
62
|
-
debug("Connected to login server");
|
|
63
|
-
soeClient.toggleEncryption(false);
|
|
64
|
-
me.emit("connect", err, result);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
soeClient.on("disconnect", function (err, result) {
|
|
68
|
-
debug("Disconnected");
|
|
69
|
-
me.emit("disconnect", err, result);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
connect(callback) {
|
|
74
|
-
debug("Connecting to gateway server");
|
|
75
|
-
this._soeClient.connect();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
sendTunnelData(tunnelData, channel) {
|
|
79
|
-
channel = channel || 0;
|
|
80
|
-
debug("Sending tunnel data to gateway server");
|
|
81
|
-
const data = this._protocol.pack("TunnelPacketFromExternalConnection", {
|
|
82
|
-
channel: channel,
|
|
83
|
-
tunnelData: tunnelData,
|
|
84
|
-
});
|
|
85
|
-
//fs.writeFileSync("dump/out_tunneldata_" + (tunnelCount++) + ".dat", data);
|
|
86
|
-
this._soeClient.sendAppData(data, true);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
login(characterId, ticket, clientProtocol, clientBuild) {
|
|
90
|
-
debug("Sending login request");
|
|
91
|
-
const data = this._protocol.pack("LoginRequest", {
|
|
92
|
-
characterId: characterId,
|
|
93
|
-
ticket: ticket,
|
|
94
|
-
clientProtocol: clientProtocol,
|
|
95
|
-
clientBuild: clientBuild,
|
|
96
|
-
});
|
|
97
|
-
//fs.writeFileSync("loginrequest.dat", data);
|
|
98
|
-
this._soeClient.sendAppData(data, false);
|
|
99
|
-
this._soeClient.toggleEncryption(true);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
disconnect() {}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
util.inherits(GatewayClient, EventEmitter);
|
|
106
|
-
|
|
107
|
-
exports.GatewayClient = GatewayClient;
|
|
1
|
+
// ======================================================================
|
|
2
|
+
//
|
|
3
|
+
// GNU GENERAL PUBLIC LICENSE
|
|
4
|
+
// Version 3, 29 June 2007
|
|
5
|
+
// copyright (C) 2020 - 2021 Quentin Gruber
|
|
6
|
+
// copyright (C) 2021 - 2022 H1emu community
|
|
7
|
+
//
|
|
8
|
+
// https://github.com/QuentinGruber/h1z1-server
|
|
9
|
+
// https://www.npmjs.com/package/h1z1-server
|
|
10
|
+
//
|
|
11
|
+
// Based on https://github.com/psemu/soe-network
|
|
12
|
+
// ======================================================================
|
|
13
|
+
|
|
14
|
+
const EventEmitter = require("events").EventEmitter,
|
|
15
|
+
SOEClient = require("./soeclient").SOEClient,
|
|
16
|
+
fs = require("fs"),
|
|
17
|
+
util = require("util"),
|
|
18
|
+
GatewayProtocol = require("../protocols/gatewayprotocol").GatewayProtocol,
|
|
19
|
+
GatewayPackets = require("../protocols/gatewayprotocol").GatewayPackets,
|
|
20
|
+
debug = require("debug")("GatewayClient");
|
|
21
|
+
|
|
22
|
+
function GatewayClientError(message) {
|
|
23
|
+
this.name = this.constructor.name;
|
|
24
|
+
this.message = message;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
util.inherits(GatewayClientError, Error);
|
|
28
|
+
|
|
29
|
+
class GatewayClient {
|
|
30
|
+
constructor(serverAddress, serverPort, key, localPort) {
|
|
31
|
+
EventEmitter.call(this);
|
|
32
|
+
|
|
33
|
+
const soeClient = (this._soeClient = new SOEClient(
|
|
34
|
+
"ExternalGatewayApi_3",
|
|
35
|
+
serverAddress,
|
|
36
|
+
serverPort,
|
|
37
|
+
key,
|
|
38
|
+
localPort
|
|
39
|
+
));
|
|
40
|
+
const protocol = (this._protocol = new GatewayProtocol());
|
|
41
|
+
const me = this;
|
|
42
|
+
|
|
43
|
+
soeClient.on("appdata", function (err, data) {
|
|
44
|
+
const packet = protocol.parse(data);
|
|
45
|
+
const result = packet.result;
|
|
46
|
+
|
|
47
|
+
switch (packet.name) {
|
|
48
|
+
case "LoginReply":
|
|
49
|
+
if (result.loggedIn) {
|
|
50
|
+
me.emit("login", null, result);
|
|
51
|
+
} else {
|
|
52
|
+
me.emit("login", new GatewayClientError("Login failed"));
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case "TunnelPacketToExternalConnection":
|
|
56
|
+
me.emit("tunneldata", null, packet.tunnelData, packet.flags);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
soeClient.on("connect", function (err, result) {
|
|
62
|
+
debug("Connected to login server");
|
|
63
|
+
soeClient.toggleEncryption(false);
|
|
64
|
+
me.emit("connect", err, result);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
soeClient.on("disconnect", function (err, result) {
|
|
68
|
+
debug("Disconnected");
|
|
69
|
+
me.emit("disconnect", err, result);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
connect(callback) {
|
|
74
|
+
debug("Connecting to gateway server");
|
|
75
|
+
this._soeClient.connect();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
sendTunnelData(tunnelData, channel) {
|
|
79
|
+
channel = channel || 0;
|
|
80
|
+
debug("Sending tunnel data to gateway server");
|
|
81
|
+
const data = this._protocol.pack("TunnelPacketFromExternalConnection", {
|
|
82
|
+
channel: channel,
|
|
83
|
+
tunnelData: tunnelData,
|
|
84
|
+
});
|
|
85
|
+
//fs.writeFileSync("dump/out_tunneldata_" + (tunnelCount++) + ".dat", data);
|
|
86
|
+
this._soeClient.sendAppData(data, true);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
login(characterId, ticket, clientProtocol, clientBuild) {
|
|
90
|
+
debug("Sending login request");
|
|
91
|
+
const data = this._protocol.pack("LoginRequest", {
|
|
92
|
+
characterId: characterId,
|
|
93
|
+
ticket: ticket,
|
|
94
|
+
clientProtocol: clientProtocol,
|
|
95
|
+
clientBuild: clientBuild,
|
|
96
|
+
});
|
|
97
|
+
//fs.writeFileSync("loginrequest.dat", data);
|
|
98
|
+
this._soeClient.sendAppData(data, false);
|
|
99
|
+
this._soeClient.toggleEncryption(true);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
disconnect() {}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
util.inherits(GatewayClient, EventEmitter);
|
|
106
|
+
|
|
107
|
+
exports.GatewayClient = GatewayClient;
|
|
@@ -1,228 +1,228 @@
|
|
|
1
|
-
// ======================================================================
|
|
2
|
-
//
|
|
3
|
-
// GNU GENERAL PUBLIC LICENSE
|
|
4
|
-
// Version 3, 29 June 2007
|
|
5
|
-
// copyright (C) 2020 - 2021 Quentin Gruber
|
|
6
|
-
// copyright (C) 2021 - 2022 H1emu community
|
|
7
|
-
//
|
|
8
|
-
// https://github.com/QuentinGruber/h1z1-server
|
|
9
|
-
// https://www.npmjs.com/package/h1z1-server
|
|
10
|
-
//
|
|
11
|
-
// Based on https://github.com/psemu/soe-network
|
|
12
|
-
// ======================================================================
|
|
13
|
-
|
|
14
|
-
import { EventEmitter } from "events";
|
|
15
|
-
|
|
16
|
-
import { SOEClient } from "./soeclient";
|
|
17
|
-
import { LoginProtocol } from "../protocols/loginprotocol";
|
|
18
|
-
|
|
19
|
-
const loginProtocolName = "LoginUdp_9";
|
|
20
|
-
const debug = require("debug")("LoginClient");
|
|
21
|
-
|
|
22
|
-
interface SoeClient {
|
|
23
|
-
on: Function;
|
|
24
|
-
emit: Function;
|
|
25
|
-
connect: Function;
|
|
26
|
-
start: Function;
|
|
27
|
-
stop: Function;
|
|
28
|
-
_sessionId: number;
|
|
29
|
-
_protocol: LoginProtocol;
|
|
30
|
-
_sendPacket: Function;
|
|
31
|
-
sendAppData: Function;
|
|
32
|
-
toggleEncryption: Function;
|
|
33
|
-
toggleDataDump: Function;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface LoginProtocolInterface {
|
|
37
|
-
parse: Function;
|
|
38
|
-
pack: Function;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class LoginClient extends EventEmitter {
|
|
42
|
-
_gameId: number;
|
|
43
|
-
_environment: string;
|
|
44
|
-
_soeClient: any;
|
|
45
|
-
_protocol: LoginProtocolInterface;
|
|
46
|
-
|
|
47
|
-
constructor(
|
|
48
|
-
gameId: number,
|
|
49
|
-
environment: string,
|
|
50
|
-
serverAddress: string,
|
|
51
|
-
serverPort: number,
|
|
52
|
-
loginKey: Uint8Array,
|
|
53
|
-
localPort: number
|
|
54
|
-
) {
|
|
55
|
-
super();
|
|
56
|
-
this._gameId = gameId;
|
|
57
|
-
this._environment = environment;
|
|
58
|
-
this._soeClient = new SOEClient(
|
|
59
|
-
loginProtocolName,
|
|
60
|
-
serverAddress,
|
|
61
|
-
serverPort,
|
|
62
|
-
loginKey,
|
|
63
|
-
localPort
|
|
64
|
-
);
|
|
65
|
-
this._protocol = new LoginProtocol();
|
|
66
|
-
let n = 0;
|
|
67
|
-
this._soeClient.on("connect", (err: string, result: string) => {
|
|
68
|
-
debug("Connected to login server");
|
|
69
|
-
this.login("FiNgErPrInT");
|
|
70
|
-
});
|
|
71
|
-
this._soeClient.on("disconnect", (err: string, result: string) => {
|
|
72
|
-
debug("Disconnected");
|
|
73
|
-
});
|
|
74
|
-
this._soeClient.on("appdata", (err: string, data: Buffer) => {
|
|
75
|
-
n++;
|
|
76
|
-
let packet, result;
|
|
77
|
-
try {
|
|
78
|
-
packet = this._protocol.parse(data);
|
|
79
|
-
} catch (e) {
|
|
80
|
-
debug("Failed parsing app data loginclient_appdata_" + n + ".dat");
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
result = packet.result;
|
|
85
|
-
|
|
86
|
-
switch (packet.name) {
|
|
87
|
-
case "LoginReply":
|
|
88
|
-
if (result.status === 1) {
|
|
89
|
-
this.emit("login", null, {
|
|
90
|
-
loggedIn: result.loggedIn,
|
|
91
|
-
isMember: result.isMember,
|
|
92
|
-
});
|
|
93
|
-
} else {
|
|
94
|
-
this.emit("login", "Login failed");
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
case "ForceDisconnect":
|
|
98
|
-
break;
|
|
99
|
-
case "CharacterLoginReply":
|
|
100
|
-
if (result.status === 1) {
|
|
101
|
-
debug(JSON.stringify(result, null, 4));
|
|
102
|
-
this.emit("characterlogin", null, result);
|
|
103
|
-
} else {
|
|
104
|
-
this.emit("characterlogin", "Character login failed");
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case "CharacterCreateReply":
|
|
108
|
-
if (result.status === 1) {
|
|
109
|
-
this.emit("charactercreate", null, {
|
|
110
|
-
characterId: result.characterId,
|
|
111
|
-
});
|
|
112
|
-
} else {
|
|
113
|
-
this.emit("charactercreate", "Character create failed");
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
case "CharacterDeleteReply":
|
|
117
|
-
if (result.status === 1) {
|
|
118
|
-
this.emit("characterdelete", null, {});
|
|
119
|
-
} else {
|
|
120
|
-
this.emit("characterdelete", "Character delete failed");
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
case "CharacterSelectInfoReply":
|
|
124
|
-
if (result.status === 1) {
|
|
125
|
-
this.emit("characterinfo", null, result);
|
|
126
|
-
} else {
|
|
127
|
-
this.emit("characterinfo", "Character info failed");
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
case "ServerListReply":
|
|
131
|
-
this.emit("serverlist", null, {
|
|
132
|
-
servers: result.servers,
|
|
133
|
-
});
|
|
134
|
-
break;
|
|
135
|
-
case "ServerUpdate":
|
|
136
|
-
if (result.status === 1) {
|
|
137
|
-
this.emit("serverupdate", null, result.server);
|
|
138
|
-
} else {
|
|
139
|
-
this.emit("serverupdate", "Server update failed");
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
case "TunnelAppPacketServerToClient":
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
connect() {
|
|
149
|
-
debug("Connecting to login server");
|
|
150
|
-
this._soeClient.connect();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async login(fingerprint: string) {
|
|
154
|
-
async function SetupLoginRequest(
|
|
155
|
-
fingerprint: any,
|
|
156
|
-
sessionId: any,
|
|
157
|
-
protocol: any
|
|
158
|
-
) {
|
|
159
|
-
const data = await protocol.pack("LoginRequest", {
|
|
160
|
-
sessionId: sessionId,
|
|
161
|
-
systemFingerPrint: fingerprint,
|
|
162
|
-
});
|
|
163
|
-
return data;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
var data = await SetupLoginRequest(
|
|
167
|
-
fingerprint,
|
|
168
|
-
this._soeClient._sessionId.toString(),
|
|
169
|
-
this._protocol
|
|
170
|
-
);
|
|
171
|
-
debug("Sending login request");
|
|
172
|
-
this._soeClient.sendAppData(data, true);
|
|
173
|
-
|
|
174
|
-
this.emit("connect");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
disconnect() {
|
|
178
|
-
this.emit("disconnect");
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
requestServerList() {
|
|
182
|
-
debug("Requesting server list");
|
|
183
|
-
const data = this._protocol.pack("ServerListRequest");
|
|
184
|
-
this._soeClient.sendAppData(data, true);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
requestCharacterInfo() {
|
|
188
|
-
debug("Requesting character info");
|
|
189
|
-
const data = this._protocol.pack("CharacterSelectInfoRequest");
|
|
190
|
-
this._soeClient.sendAppData(data, true);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
requestCharacterLogin(characterId: string, serverId: number, payload: any) {
|
|
194
|
-
debug("Requesting character login");
|
|
195
|
-
const data = this._protocol.pack("CharacterLoginRequest", {
|
|
196
|
-
characterId: characterId,
|
|
197
|
-
serverId: serverId,
|
|
198
|
-
payload: payload,
|
|
199
|
-
});
|
|
200
|
-
if (data) {
|
|
201
|
-
this._soeClient.sendAppData(data, true);
|
|
202
|
-
} else {
|
|
203
|
-
debug("Could not pack character login request data");
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
requestCharacterDelete = function () {};
|
|
208
|
-
|
|
209
|
-
requestCharacterCreate() {
|
|
210
|
-
debug("Requesting character create");
|
|
211
|
-
const data = this._protocol.pack("CharacterCreateRequest", {
|
|
212
|
-
serverId: 1,
|
|
213
|
-
unknown: 0,
|
|
214
|
-
payload: {
|
|
215
|
-
empireId: 2,
|
|
216
|
-
headType: 1,
|
|
217
|
-
profileType: 3,
|
|
218
|
-
gender: 1,
|
|
219
|
-
characterName: "test",
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
if (data) {
|
|
223
|
-
this._soeClient.sendAppData(data, true);
|
|
224
|
-
} else {
|
|
225
|
-
debug("Could not pack character create request data");
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
1
|
+
// ======================================================================
|
|
2
|
+
//
|
|
3
|
+
// GNU GENERAL PUBLIC LICENSE
|
|
4
|
+
// Version 3, 29 June 2007
|
|
5
|
+
// copyright (C) 2020 - 2021 Quentin Gruber
|
|
6
|
+
// copyright (C) 2021 - 2022 H1emu community
|
|
7
|
+
//
|
|
8
|
+
// https://github.com/QuentinGruber/h1z1-server
|
|
9
|
+
// https://www.npmjs.com/package/h1z1-server
|
|
10
|
+
//
|
|
11
|
+
// Based on https://github.com/psemu/soe-network
|
|
12
|
+
// ======================================================================
|
|
13
|
+
|
|
14
|
+
import { EventEmitter } from "events";
|
|
15
|
+
|
|
16
|
+
import { SOEClient } from "./soeclient";
|
|
17
|
+
import { LoginProtocol } from "../protocols/loginprotocol";
|
|
18
|
+
|
|
19
|
+
const loginProtocolName = "LoginUdp_9";
|
|
20
|
+
const debug = require("debug")("LoginClient");
|
|
21
|
+
|
|
22
|
+
interface SoeClient {
|
|
23
|
+
on: Function;
|
|
24
|
+
emit: Function;
|
|
25
|
+
connect: Function;
|
|
26
|
+
start: Function;
|
|
27
|
+
stop: Function;
|
|
28
|
+
_sessionId: number;
|
|
29
|
+
_protocol: LoginProtocol;
|
|
30
|
+
_sendPacket: Function;
|
|
31
|
+
sendAppData: Function;
|
|
32
|
+
toggleEncryption: Function;
|
|
33
|
+
toggleDataDump: Function;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface LoginProtocolInterface {
|
|
37
|
+
parse: Function;
|
|
38
|
+
pack: Function;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class LoginClient extends EventEmitter {
|
|
42
|
+
_gameId: number;
|
|
43
|
+
_environment: string;
|
|
44
|
+
_soeClient: any;
|
|
45
|
+
_protocol: LoginProtocolInterface;
|
|
46
|
+
|
|
47
|
+
constructor(
|
|
48
|
+
gameId: number,
|
|
49
|
+
environment: string,
|
|
50
|
+
serverAddress: string,
|
|
51
|
+
serverPort: number,
|
|
52
|
+
loginKey: Uint8Array,
|
|
53
|
+
localPort: number
|
|
54
|
+
) {
|
|
55
|
+
super();
|
|
56
|
+
this._gameId = gameId;
|
|
57
|
+
this._environment = environment;
|
|
58
|
+
this._soeClient = new SOEClient(
|
|
59
|
+
loginProtocolName,
|
|
60
|
+
serverAddress,
|
|
61
|
+
serverPort,
|
|
62
|
+
loginKey,
|
|
63
|
+
localPort
|
|
64
|
+
);
|
|
65
|
+
this._protocol = new LoginProtocol();
|
|
66
|
+
let n = 0;
|
|
67
|
+
this._soeClient.on("connect", (err: string, result: string) => {
|
|
68
|
+
debug("Connected to login server");
|
|
69
|
+
this.login("FiNgErPrInT");
|
|
70
|
+
});
|
|
71
|
+
this._soeClient.on("disconnect", (err: string, result: string) => {
|
|
72
|
+
debug("Disconnected");
|
|
73
|
+
});
|
|
74
|
+
this._soeClient.on("appdata", (err: string, data: Buffer) => {
|
|
75
|
+
n++;
|
|
76
|
+
let packet, result;
|
|
77
|
+
try {
|
|
78
|
+
packet = this._protocol.parse(data);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
debug("Failed parsing app data loginclient_appdata_" + n + ".dat");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
result = packet.result;
|
|
85
|
+
|
|
86
|
+
switch (packet.name) {
|
|
87
|
+
case "LoginReply":
|
|
88
|
+
if (result.status === 1) {
|
|
89
|
+
this.emit("login", null, {
|
|
90
|
+
loggedIn: result.loggedIn,
|
|
91
|
+
isMember: result.isMember,
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
this.emit("login", "Login failed");
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
case "ForceDisconnect":
|
|
98
|
+
break;
|
|
99
|
+
case "CharacterLoginReply":
|
|
100
|
+
if (result.status === 1) {
|
|
101
|
+
debug(JSON.stringify(result, null, 4));
|
|
102
|
+
this.emit("characterlogin", null, result);
|
|
103
|
+
} else {
|
|
104
|
+
this.emit("characterlogin", "Character login failed");
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "CharacterCreateReply":
|
|
108
|
+
if (result.status === 1) {
|
|
109
|
+
this.emit("charactercreate", null, {
|
|
110
|
+
characterId: result.characterId,
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
this.emit("charactercreate", "Character create failed");
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
case "CharacterDeleteReply":
|
|
117
|
+
if (result.status === 1) {
|
|
118
|
+
this.emit("characterdelete", null, {});
|
|
119
|
+
} else {
|
|
120
|
+
this.emit("characterdelete", "Character delete failed");
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case "CharacterSelectInfoReply":
|
|
124
|
+
if (result.status === 1) {
|
|
125
|
+
this.emit("characterinfo", null, result);
|
|
126
|
+
} else {
|
|
127
|
+
this.emit("characterinfo", "Character info failed");
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "ServerListReply":
|
|
131
|
+
this.emit("serverlist", null, {
|
|
132
|
+
servers: result.servers,
|
|
133
|
+
});
|
|
134
|
+
break;
|
|
135
|
+
case "ServerUpdate":
|
|
136
|
+
if (result.status === 1) {
|
|
137
|
+
this.emit("serverupdate", null, result.server);
|
|
138
|
+
} else {
|
|
139
|
+
this.emit("serverupdate", "Server update failed");
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
case "TunnelAppPacketServerToClient":
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
connect() {
|
|
149
|
+
debug("Connecting to login server");
|
|
150
|
+
this._soeClient.connect();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async login(fingerprint: string) {
|
|
154
|
+
async function SetupLoginRequest(
|
|
155
|
+
fingerprint: any,
|
|
156
|
+
sessionId: any,
|
|
157
|
+
protocol: any
|
|
158
|
+
) {
|
|
159
|
+
const data = await protocol.pack("LoginRequest", {
|
|
160
|
+
sessionId: sessionId,
|
|
161
|
+
systemFingerPrint: fingerprint,
|
|
162
|
+
});
|
|
163
|
+
return data;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var data = await SetupLoginRequest(
|
|
167
|
+
fingerprint,
|
|
168
|
+
this._soeClient._sessionId.toString(),
|
|
169
|
+
this._protocol
|
|
170
|
+
);
|
|
171
|
+
debug("Sending login request");
|
|
172
|
+
this._soeClient.sendAppData(data, true);
|
|
173
|
+
|
|
174
|
+
this.emit("connect");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
disconnect() {
|
|
178
|
+
this.emit("disconnect");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
requestServerList() {
|
|
182
|
+
debug("Requesting server list");
|
|
183
|
+
const data = this._protocol.pack("ServerListRequest");
|
|
184
|
+
this._soeClient.sendAppData(data, true);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
requestCharacterInfo() {
|
|
188
|
+
debug("Requesting character info");
|
|
189
|
+
const data = this._protocol.pack("CharacterSelectInfoRequest");
|
|
190
|
+
this._soeClient.sendAppData(data, true);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
requestCharacterLogin(characterId: string, serverId: number, payload: any) {
|
|
194
|
+
debug("Requesting character login");
|
|
195
|
+
const data = this._protocol.pack("CharacterLoginRequest", {
|
|
196
|
+
characterId: characterId,
|
|
197
|
+
serverId: serverId,
|
|
198
|
+
payload: payload,
|
|
199
|
+
});
|
|
200
|
+
if (data) {
|
|
201
|
+
this._soeClient.sendAppData(data, true);
|
|
202
|
+
} else {
|
|
203
|
+
debug("Could not pack character login request data");
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
requestCharacterDelete = function () {};
|
|
208
|
+
|
|
209
|
+
requestCharacterCreate() {
|
|
210
|
+
debug("Requesting character create");
|
|
211
|
+
const data = this._protocol.pack("CharacterCreateRequest", {
|
|
212
|
+
serverId: 1,
|
|
213
|
+
unknown: 0,
|
|
214
|
+
payload: {
|
|
215
|
+
empireId: 2,
|
|
216
|
+
headType: 1,
|
|
217
|
+
profileType: 3,
|
|
218
|
+
gender: 1,
|
|
219
|
+
characterName: "test",
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
if (data) {
|
|
223
|
+
this._soeClient.sendAppData(data, true);
|
|
224
|
+
} else {
|
|
225
|
+
debug("Could not pack character create request data");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|