mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-10-24 00:52:38 -05:00
Update
- Adding protos - Adding dumps - Simple http server - Various packets - Added readme
This commit is contained in:
30
src/index.js
30
src/index.js
@@ -1,5 +1,7 @@
|
||||
import fs from "fs";
|
||||
import http from "http";
|
||||
import proto from "./proto";
|
||||
import querystring from "querystring";
|
||||
|
||||
import { inherit } from "./utils";
|
||||
|
||||
@@ -43,17 +45,30 @@ class GameServer {
|
||||
}
|
||||
|
||||
createHTTPServer() {
|
||||
this.socket = http.createServer(this.onRequest).listen(CFG.SERVER_PORT);
|
||||
this.socket = http.createServer((req) => {
|
||||
let chunks = [];
|
||||
req.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
req.on("end", () => {
|
||||
let buffer = Buffer.concat(chunks);
|
||||
this.onRequest(buffer);
|
||||
});
|
||||
}).listen(CFG.SERVER_PORT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Request} req
|
||||
* @param {Response} resp
|
||||
* @param {Buffer} body
|
||||
*/
|
||||
onRequest(req, resp) {
|
||||
if (this.validRequest(req)) {
|
||||
this.answer(valid);
|
||||
}
|
||||
onRequest(body) {
|
||||
|
||||
let request = proto.Networking.Envelopes.RequestEnvelope.decode(body);
|
||||
|
||||
console.log("Got request");
|
||||
console.log("Received:", request.requests.map((request) => {
|
||||
return request.request_type;
|
||||
}).join(","));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +76,6 @@ class GameServer {
|
||||
* @return {Boolean}
|
||||
*/
|
||||
validRequest(req) {
|
||||
console.log(req);
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
15
src/packets/Responses.DownloadRemoteConfigVersion.js
Normal file
15
src/packets/Responses.DownloadRemoteConfigVersion.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import proto from "../proto";
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function DownloadRemoteConfigVersion(obj) {
|
||||
|
||||
return (
|
||||
new proto.Networking.Responses.DownloadSettingsResponse({
|
||||
hash: "54b359c97e46900f87211ef6e6dd0b7f2a3ea1f5"
|
||||
}).encode();
|
||||
);
|
||||
|
||||
}
|
||||
15
src/packets/Responses.DownloadSettings.js
Normal file
15
src/packets/Responses.DownloadSettings.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import proto from "../proto";
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function DownloadSettings(obj) {
|
||||
|
||||
return (
|
||||
new proto.Networking.Responses.DownloadSettingsResponse({
|
||||
hash: "54b359c97e46900f87211ef6e6dd0b7f2a3ea1f5"
|
||||
}).encode();
|
||||
);
|
||||
|
||||
}
|
||||
15
src/packets/Responses.GetAssetDigest.js
Normal file
15
src/packets/Responses.GetAssetDigest.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as CFG from "../cfg";
|
||||
|
||||
import proto from "../proto";
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function GetAssetDigest(obj) {
|
||||
|
||||
return (
|
||||
fs.readFileSync(CFG.ASSET_DIGEST_PATH)
|
||||
);
|
||||
|
||||
}
|
||||
19
src/packets/Responses.GetHatchedEggs.js
Normal file
19
src/packets/Responses.GetHatchedEggs.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import proto from "../proto";
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function GetHatchedEggs(obj) {
|
||||
|
||||
return (
|
||||
new proto.Networking.Responses.GetHatchedEggsResponse({
|
||||
success: true,
|
||||
pokemon_id: [],
|
||||
experience_awarded: [],
|
||||
candy_awarded: [],
|
||||
stardust_awarded: []
|
||||
}).encode()
|
||||
);
|
||||
|
||||
}
|
||||
52
src/packets/Responses.GetInventory.js
Normal file
52
src/packets/Responses.GetInventory.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import proto from "../proto";
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function GetInventoryData(obj) {
|
||||
|
||||
return (
|
||||
new proto.Networking.Responses.GetInventoryResponse({
|
||||
success: true,
|
||||
inventory_delta: new proto.Inventory.InventoryDelta({
|
||||
original_timestamp_ms: new Date().getTime * 1000,
|
||||
new_timestamp_ms: new Date().getTime * 1000,
|
||||
inventory_items: [
|
||||
new proto.Inventory.InventoryItem({
|
||||
inventory_item_data: new proto.Inventory.InventoryItemData({
|
||||
pokemon_data: new proto.Data.PokemonData({
|
||||
id: 123781297398,
|
||||
pokemon_id: 25,
|
||||
cp: 10000000000,
|
||||
is_egg: false,
|
||||
height_m: 100,
|
||||
weight_kg: 1,
|
||||
move_1: 219,
|
||||
move_2: 26,
|
||||
deployed_fort_id: 0,
|
||||
owner_name: "",
|
||||
origin: 0,
|
||||
individual_attack: 100,
|
||||
individual_defense: 100,
|
||||
individual_stamina: 100,
|
||||
cp_multiplier: 100,
|
||||
pokeball: 1,
|
||||
creation_time_ms: new Date().getTime() * 1000
|
||||
})
|
||||
})
|
||||
}),
|
||||
new proto.Inventory.InventoryItem({
|
||||
inventory_item_data: new proto.Inventory.InventoryItemData({
|
||||
item: new proto.Inventory.Item({
|
||||
item_id: 4,
|
||||
count: 1000
|
||||
})
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
}).encode()
|
||||
);
|
||||
|
||||
}
|
||||
90
src/packets/Responses.GetPlayer.js
Normal file
90
src/packets/Responses.GetPlayer.js
Normal file
@@ -0,0 +1,90 @@
|
||||
import proto from "../proto";
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
function getPlayerDataPacket(obj) {
|
||||
|
||||
return new proto.Data.PlayerData({
|
||||
creation_timestamp_ms: 1467936859925,
|
||||
username: obj.username,
|
||||
team: obj.team,
|
||||
tutorial_state: obj.tutorial_state,
|
||||
avatar: new proto.Data.Player.PlayerAvatar(obj.avatar),
|
||||
max_pokemon_storage: 250,
|
||||
max_item_storage: 350,
|
||||
daily_bonus: new proto.Data.Player.DailyBonus({
|
||||
next_defender_bonus_collect_timestamp_ms: 1470174535972
|
||||
}),
|
||||
contact_settings: new proto.Data.Player.ContactSettings({
|
||||
send_marketing_emails: true
|
||||
}),
|
||||
currencies: obj.currencies
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
function buildPlayerData(obj) {
|
||||
|
||||
let team = obj.team;
|
||||
let username = obj.username;
|
||||
|
||||
let pokecoins = obj.pokecoins;
|
||||
let stardust = obj.stardust;
|
||||
|
||||
let avatar = {
|
||||
skin: 2,
|
||||
hair: 2,
|
||||
shirt: 1,
|
||||
pants: 2,
|
||||
hat: 1,
|
||||
eyes: 3,
|
||||
backpack: 1
|
||||
};
|
||||
|
||||
let tutorial_state = [0, 1, 3, 4, 7];
|
||||
|
||||
let currencies = [
|
||||
new proto.Data.Player.Currency({
|
||||
name: "POKECOIN",
|
||||
amount: pokecoins
|
||||
}),
|
||||
new proto.Data.Player.Currency({
|
||||
name: "STARDUST",
|
||||
amount: stardust
|
||||
})
|
||||
];
|
||||
|
||||
return ({
|
||||
username: username,
|
||||
team: team,
|
||||
tutorial_state: tutorial_state,
|
||||
avatar: avatar,
|
||||
currencies: currencies
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function GetPlayer(obj) {
|
||||
|
||||
let data = buildPlayerData(obj);
|
||||
|
||||
let packet = getPlayerDataPacket(data);
|
||||
|
||||
return (
|
||||
new proto.Networking.Responses.GetPlayerResponse({
|
||||
success: true,
|
||||
player_data: packet
|
||||
}).encode()
|
||||
);
|
||||
|
||||
}
|
||||
7
src/packets/index.js
Normal file
7
src/packets/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export DownloadRemoteConfigVersion from "./Responses.DownloadRemoteConfigVersion";
|
||||
export DownloadSettings from "./Responses.DownloadSettings";
|
||||
|
||||
export GetAssetDigest from "./Responses.GetAssetDigest";
|
||||
export GetHatchedEggs from "./Responses.GetHatchedEggs";
|
||||
export GetInventory from "./Responses.GetInventory";
|
||||
export GetPlayer from "./Responses.GetPlayer";
|
||||
@@ -31,7 +31,7 @@ export function uncaughtException(excp) {
|
||||
this.print("No root privileges!", 31);
|
||||
break;
|
||||
default:
|
||||
console.log("Unhandled exception occurred: ", code);
|
||||
console.log("Unhandled exception occurred: ", excp.code);
|
||||
console.log(excp.stack);
|
||||
break;
|
||||
};
|
||||
|
||||
4
src/proto.js
Normal file
4
src/proto.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import protobuf from "protobufjs";
|
||||
import path from "path";
|
||||
|
||||
export default protobuf.loadProtoFile({ root: path.join(__dirname, "../"), file: "POGOProtos/POGOProtos.proto" }).build("POGOProtos");
|
||||
@@ -1,15 +1,11 @@
|
||||
import path from "path";
|
||||
|
||||
import proto from "pkmngo-proto";
|
||||
|
||||
import * as CFG from "../cfg";
|
||||
|
||||
export function setup() {
|
||||
|
||||
this.print("Booting server...", 33);
|
||||
|
||||
this.proto = proto;
|
||||
|
||||
if (CFG.SERVER_PORT < 1) {
|
||||
this.print("Invalid port!", 31);
|
||||
return void 0;
|
||||
|
||||
Reference in New Issue
Block a user