Mega Update

- Removed mongodb
- Validate dumped assets (game master, asset digest, models)
- Added pokemon_owned table
- Added items to users table
- Outsourced table structures into seperate folder
- Added pokemongo-protobuf lib
- Reworked mysql wrapper
- Dump game master
- Allow ptc connections, but alert, that progress wont be saved
- Fixed https://github.com/maierfelix/POGOserver/issues/13
This commit is contained in:
Felix
2016-08-21 21:13:26 +02:00
parent d8bf726f3c
commit 9905d60441
35 changed files with 4160 additions and 1275 deletions

View File

@@ -19,13 +19,8 @@ export default {
MYSQL_DB_NAME: "pogosql",
MYSQL_USERNAME: "root",
MYSQL_PASSWORD: "",
MYSQL_TABLE: "users",
// MongoDB credentials
MONGO_PORT: 27017,
MONGO_HOST_IP: "127.0.0.1",
MONGO_DB_NAME: "pokemongo",
MONGO_COLLECTION_USERS: "users",
MYSQL_USERS_TABLE: "users",
MYSQL_OWNED_PKMN_TABLE: "owned_pkmn",
// Used for asset download session
DOWNLOAD_PROVIDER: "GOOGLE",
@@ -36,7 +31,7 @@ export default {
GMAPS_KEY: "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM",
// Server debug options
DEBUG_DUMP_PATH: "./logs/",
DEBUG_DUMP_PATH: "logs/",
DEBUG_DUMP_TRAFFIC: true,
DEBUG_LOG_REQUESTS: true,

View File

@@ -33,6 +33,7 @@
"directory-tree": "^1.1.0",
"nodegit": "^0.14.1",
"fs-extra": "^0.30.0",
"pokemongo-protobuf": "^1.10.0",
"pcrypt": "git+https://github.com/laverdet/pcrypt.git"
},
"devDependencies": {}

48
src/db/create.js Normal file
View File

@@ -0,0 +1,48 @@
import fs from "fs";
import CFG from "../../cfg";
export function createTableIfNoExists(name) {
return new Promise((resolve) => {
this.db.instance.query(`SHOW TABLES LIKE '${name}';`, (e, rows, fields) => {
if (e) console.log(e);
else {
// exists
if (rows && rows.length) resolve();
// create user table
else this.createTables().then(resolve);
}
});
});
}
/**
* @param {String} name
*/
export function createTables() {
return new Promise((resolve) => {
this.createTable(CFG.MYSQL_USERS_TABLE).then(() => {
this.createTable(CFG.MYSQL_OWNED_PKMN_TABLE).then(() => {
resolve();
});
});
});
}
export function createTable(name) {
this.print(`Creating table ${name}`, 36);
let query = `
CREATE TABLE ${name} (
${fs.readFileSync(__dirname + "/tables/" + name + ".table", "utf8")}
) ENGINE=InnoDB;
`;
return new Promise((resolve) => {
this.db.instance.query(query, (e, rows) => {
if (e) console.log(e);
else resolve();
});
});
}

51
src/db/get.js Normal file
View File

@@ -0,0 +1,51 @@
import CFG from "../../cfg";
/**
* @param {String} column
* @param {String} value
* @param {String} table
*/
export function getQueryByColumnFromTable(column, value, table) {
return new Promise((resolve) => {
this.db.instance.query(`SELECT * FROM ${table} WHERE ${column}=? LIMIT 1`, [value], (e, rows) => {
if (e) console.log(e);
if (rows && rows.length) resolve(rows[0]);
else resolve(void 0);
});
});
}
/**
* @param {String} column
* @param {String} value
*/
export function getPkmnByColumn(column, value) {
return new Promise((resolve) => {
this.getQueryByColumnFromTable(column, value, CFG.MYSQL_OWNED_PKMN_TABLE).then((query) => {
resolve(query);
});
});
}
/**
* @param {String} column
* @param {String} value
*/
export function getUserByColumn(column, value) {
return new Promise((resolve) => {
this.getQueryByColumnFromTable(column, value, CFG.MYSQL_USERS_TABLE).then((query) => {
resolve(query);
});
});
}
/**
* @param {String} email
*/
export function getUserByEmail(email) {
return new Promise((resolve) => {
this.getQueryByColumnFromTable("email", email, CFG.MYSQL_USERS_TABLE).then((query) => {
resolve(query);
});
});
}

74
src/db/index.js Normal file
View File

@@ -0,0 +1,74 @@
import fs from "fs";
import mysql from "mysql";
import CFG from "../../cfg";
export function setupConnection() {
let connection = mysql.createConnection({
host : CFG.MYSQL_HOST_IP,
port : CFG.MYSQL_PORT,
database : CFG.MYSQL_DB_NAME,
user : CFG.MYSQL_USERNAME,
password : CFG.MYSQL_PASSWORD
});
return new Promise((resolve) => {
connection.connect((error) => {
if (error) {
this.print("MySQL " + error, 31);
this.retry("Retrying again in ", () => this.setupConnection().then(resolve), 5);
return void 0;
}
this.db.instance = connection;
this.createTableIfNoExists(CFG.MYSQL_USERS_TABLE).then(() => {
this.createTableIfNoExists(CFG.MYSQL_OWNED_PKMN_TABLE).then(() => {
this.print(`\x1b[36;1mMySQL\x1b[0m\x1b[32;1m connection established\x1b[0m`);
resolve();
});
});
});
connection.on("error", (error) => {
this.print("MySQL " + error, 31);
this.retry("Trying to reconnect in ", () => this.setupConnection().then(resolve), 5);
});
});
}
/**
* @param {Function} resolve
*/
export function closeConnection(resolve) {
this.db.instance.end(() => {
resolve();
});
}
/**
* @param {Object} obj
*/
export function createUser(obj) {
let query = this.getUserQuery("INSERT INTO", "");
let data = this.getUserQueryData(obj);
return new Promise((resolve) => {
this.db.instance.query(query, data, resolve);
});
}
/**
* @param {Object} obj
*/
export function updateUser(obj) {
let query = this.getUserQuery("UPDATE", "WHERE email=? LIMIT 1");
let data = this.getUserQueryData(obj);
return new Promise((resolve) => {
this.db.instance.query(query, data, resolve);
});
}

View File

@@ -1,152 +0,0 @@
import mongodb from "mongodb";
import CFG from "../../cfg";
export function setupConnection() {
let url = `mongodb://${CFG.MONGO_HOST_IP}:${CFG.MONGO_PORT}/${CFG.MONGO_DB_NAME}`;
return new Promise((resolve) => {
mongodb.MongoClient.connect(url, (error, db) => {
if (error) {
this.print("MongoDB " + error, 31);
this.retry("Retrying again in ", () => this.setupConnection().then(resolve), 5);
return void 0;
} else {
this.db.instance = db;
this.loadCollection(CFG.MONGO_COLLECTION_USERS).then(() => {
this.print(`\x1b[36;1mMongoDB\x1b[0m\x1b[32;1m connection established\x1b[0m`);
resolve();
});
}
db.on("close", (error) => {
this.print("MongoDB " + error, 31);
this.retry("Trying to reconnect in ", () => this.setupConnection().then(resolve), 5);
});
});
});
}
/**
* @param {Function} resolve
*/
export function closeConnection(resolve) {
this.db.instance.close(() => {
resolve();
});
}
/**
* @param {String} name
*/
export function loadCollection(name) {
return new Promise((resolve) => {
this.db.instance.listCollections({name: name}).next((err, exists) => {
if (!exists) this.createCollection(name).then((coll) => resolve());
else {
this.db.instance.collection(name, (err, coll) => {
resolve();
});
}
});
});
}
/**
* @param {String} name
*/
export function createCollection(name) {
return new Promise((resolve) => {
this.db.instance.createCollection(name, {}, (err, coll) => {
resolve();
});
});
}
/**
* @param {String} email
*/
export function getUserByEmail(email) {
return new Promise((resolve) => {
let collection = this.getUserCollection();
collection.find({email: email}).toArray((err, docs) => {
if (docs && docs.length) resolve(docs[0]);
else resolve(void 0);
});
});
}
export function getUserCollection() {
return (
this.db.instance.collection(CFG.MONGO_COLLECTION_USERS)
);
}
/**
* @param {Object} obj
*/
export function createUser(obj) {
let collection = this.getUserCollection();
let user = this.getUserData(obj);
return new Promise((resolve) => {
collection.insert([user], (error, result) => {
resolve();
});
});
}
/**
* @param {Object} obj
*/
export function updateUser(obj) {
let collection = this.getUserCollection();
let user = this.getUserData(obj);
return new Promise((resolve) => {
collection.update({email: user.email}, user, (error, result) => {
resolve();
});
});
}
/**
* @param {Object} obj
* @return {Object}
*/
export function getUserData(obj) {
return ({
username: obj.username,
email: obj.email,
exp: obj.exp,
stardust: obj.stardust,
pokecoins: obj.pokecoins,
team: obj.team,
skin: obj.skin,
hair: obj.hair,
shirt: obj.shirt,
pants: obj.pants,
hat: obj.hat,
shoes: obj.shoes,
eyes: obj.eyes,
gender: obj.gender,
backpack: obj.backpack,
latitude: obj.latitude,
longitude: obj.latitude,
altitude: obj.latitude,
send_marketing_emails: false,
send_push_notifications: false
});
}

View File

@@ -1,204 +0,0 @@
import mysql from "mysql";
import CFG from "../../cfg";
export function setupConnection() {
let connection = mysql.createConnection({
host : CFG.MYSQL_HOST_IP,
port : CFG.MYSQL_PORT,
database : CFG.MYSQL_DB_NAME,
user : CFG.MYSQL_USERNAME,
password : CFG.MYSQL_PASSWORD
});
return new Promise((resolve) => {
connection.connect((error) => {
if (error) {
this.print("MySQL " + error, 31);
this.retry("Retrying again in ", () => this.setupConnection().then(resolve), 5);
return void 0;
}
this.db.instance = connection;
this.createTableIfNoExists().then(() => {
this.print(`\x1b[36;1mMySQL\x1b[0m\x1b[32;1m connection established\x1b[0m`);
resolve();
});
});
connection.on("error", (error) => {
this.print("MySQL " + error, 31);
this.retry("Trying to reconnect in ", () => this.setupConnection().then(resolve), 5);
});
});
}
/**
* @param {Function} resolve
*/
export function closeConnection(resolve) {
this.db.instance.end(() => {
resolve();
});
}
export function createTableIfNoExists() {
return new Promise((resolve) => {
this.db.instance.query(`SHOW TABLES LIKE '${CFG.MYSQL_TABLE}';`, (e, rows, fields) => {
if (e) console.log(e);
else {
// exists
if (rows && rows.length) resolve();
// create user table
else this.createTable(CFG.MYSQL_TABLE).then(resolve);
}
});
});
}
/**
* @param {String} name
*/
export function createTable(name) {
this.print(`Creating table ${CFG.MYSQL_TABLE}`, 36);
return new Promise((resolve) => {
let query = `
CREATE TABLE ${name} (
id int(11) NOT NULL AUTO_INCREMENT,
username longtext NOT NULL,
email longtext NOT NULL,
exp int(255) NOT NULL,
stardust int(255) NOT NULL,
pokecoins int(255) NOT NULL,
team int(11) NOT NULL,
latitude double NOT NULL,
longitude double NOT NULL,
altitude int(255) NOT NULL,
send_marketing_emails tinyint(1) NOT NULL,
send_push_notifications tinyint(1) NOT NULL,
skin int(11) NOT NULL,
hair int(11) NOT NULL,
shirt int(11) NOT NULL,
pants int(11) NOT NULL,
hat int(11) NOT NULL,
shoes int(11) NOT NULL,
eyes int(11) NOT NULL,
gender int(11) NOT NULL,
backpack int(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
`;
this.db.instance.query(query, (e, rows, fields) => {
if (e) console.log(e);
else resolve();
});
});
}
/**
* @param {String} email
*/
export function getUserByEmail(email) {
return new Promise((resolve) => {
this.db.instance.query(`SELECT * FROM ${CFG.MYSQL_TABLE} WHERE email=? LIMIT 1`, [email], (e, rows, fields) => {
if (e) console.log(e);
if (rows && rows.length) resolve(rows[0]);
else resolve(void 0);
});
});
}
/**
* @param {Object} obj
*/
export function createUser(obj) {
let query = this.getUserQuery("INSERT INTO", "");
let data = this.getUserQueryData(obj);
return new Promise((resolve) => {
this.db.instance.query(query, data, resolve);
});
}
/**
* @param {Object} obj
*/
export function updateUser(obj) {
let query = this.getUserQuery("UPDATE", "WHERE email=? LIMIT 1");
let data = this.getUserQueryData(obj);
return new Promise((resolve) => {
this.db.instance.query(query, data, resolve);
});
}
/**
* @return {String}
*/
export function getUserQuery(cmd, after) {
return (`
${cmd} ${CFG.MYSQL_TABLE}
SET
username=?,
email=?,
exp=?,
stardust=?,
pokecoins=?,
team=?,
latitude=?,
longitude=?,
altitude=?,
send_marketing_emails=?,
send_push_notifications=?,
skin=?,
hair=?,
shirt=?,
pants=?,
hat=?,
shoes=?,
eyes=?,
gender=?,
backpack=?
${after}
`);
}
/**
* @param {Object} obj
* @return {Array}
*/
export function getUserQueryData(obj) {
return ([
obj.username,
obj.email,
obj.exp,
obj.stardust,
obj.pokecoins,
obj.team,
// position
obj.latitude,
obj.longitude,
obj.altitude,
// contact settings
obj.send_marketing_emails,
obj.send_push_notifications,
// avatar
obj.skin,
obj.hair,
obj.shirt,
obj.pants,
obj.hat,
obj.shoes,
obj.eyes,
obj.gender,
obj.backpack,
// where
obj.email
]);
}

113
src/db/query.js Normal file
View File

@@ -0,0 +1,113 @@
import CFG from "../../cfg";
/**
* @return {String}
*/
export function getUserQuery(cmd, after) {
return (`
${cmd} ${CFG.MYSQL_USERS_TABLE}
SET
username=?,
email=?,
exp=?,
stardust=?,
pokecoins=?,
team=?,
latitude=?,
longitude=?,
altitude=?,
send_marketing_emails=?,
send_push_notifications=?,
skin=?,
hair=?,
shirt=?,
pants=?,
hat=?,
shoes=?,
eyes=?,
gender=?,
backpack=?
${after}
`);
}
export function getUserItemQuery(cmd, after) {
return (`
${cmd} ${CFG.MYSQL_USERS_TABLE}
SET
item_poke_ball=?,
item_great_ball=?,
item_ultra_ball=?,
item_master_ball=?,
item_potion=?,
item_super_potion=?,
item_hyper_potion=?,
item_max_potion=?,
item_revive=?,
item_max_revive=?,
item_lucky_egg=?,
item_incense_ordinary=?,
item_incense_spicy=?,
item_incense_cool=?,
item_incense_floral=?,
item_troy_disk=?,
item_razz_berry=?,
item_bluk_berry=?,
item_nanab_berry=?,
item_wepar_berry=?,
item_pinap_berry=?,
item_incubator_basic=?,
item_incubator_basic_unlimited=?,
item_pokemon_storage_upgrade=?,
item_item_storage_upgrade=?
${after}
`);
}
/**
* @param {Object} obj
* @return {Array}
*/
export function getUserItemQueryData(obj) {
console.log(obj);
return ([]);
}
/**
* @param {Object} obj
* @return {Array}
*/
export function getUserQueryData(obj) {
return ([
obj.username,
obj.email,
obj.exp,
obj.stardust,
obj.pokecoins,
obj.team,
// position
obj.latitude,
obj.longitude,
obj.altitude,
// contact settings
obj.send_marketing_emails,
obj.send_push_notifications,
// avatar
obj.skin,
obj.hair,
obj.shirt,
obj.pants,
obj.hat,
obj.shoes,
obj.eyes,
obj.gender,
obj.backpack,
// where
obj.email
]);
}

View File

@@ -0,0 +1,30 @@
id int(11) NOT NULL AUTO_INCREMENT,
owner_id int(11) NOT NULL,
pokemon_id int(11) NOT NULL,
stamina int(11) NOT NULL,
stamina_max int(11) NOT NULL,
move_1 int(5) NOT NULL,
move_2 int(5) NOT NULL,
deployed_fort_id longtext NOT NULL,
is_egg tinyint(1) NOT NULL,
egg_km_walked_target double NOT NULL,
egg_km_walked_start double NOT NULL,
origin int(11) NOT NULL,
height_m double NOT NULL,
weight_kg double NOT NULL,
individual_attack int(11) NOT NULL,
individual_defense int(11) NOT NULL,
individual_stamina int(11) NOT NULL,
cp_multiplier double NOT NULL,
pokeball int(3) NOT NULL,
captured_cell_id int(11) NOT NULL,
battles_attacked int(11) NOT NULL,
battles_defended int(11) NOT NULL,
egg_incubator_id longtext NOT NULL,
creation_time_ms int(11) NOT NULL,
num_upgrades int(11) NOT NULL,
additional_cp_multiplier double NOT NULL,
favorite tinyint(1) NOT NULL,
nickname longtext NOT NULL,
from_fort int(11) NOT NULL,
PRIMARY KEY (id)

47
src/db/tables/users.table Normal file
View File

@@ -0,0 +1,47 @@
id int(11) NOT NULL AUTO_INCREMENT,
username longtext NOT NULL,
email longtext NOT NULL,
exp int(255) NOT NULL,
stardust int(255) NOT NULL,
pokecoins int(255) NOT NULL,
team int(11) NOT NULL,
latitude double NOT NULL,
longitude double NOT NULL,
altitude int(255) NOT NULL,
send_marketing_emails tinyint(1) NOT NULL,
send_push_notifications tinyint(1) NOT NULL,
skin int(11) NOT NULL,
hair int(11) NOT NULL,
shirt int(11) NOT NULL,
pants int(11) NOT NULL,
hat int(11) NOT NULL,
shoes int(11) NOT NULL,
eyes int(11) NOT NULL,
gender int(11) NOT NULL,
backpack int(11) NOT NULL,
item_poke_ball int(11) NOT NULL,
item_great_ball int(11) NOT NULL,
item_ultra_ball int(11) NOT NULL,
item_master_ball int(11) NOT NULL,
item_potion int(11) NOT NULL,
item_super_potion int(11) NOT NULL,
item_hyper_potion int(11) NOT NULL,
item_max_potion int(11) NOT NULL,
item_revive int(11) NOT NULL,
item_max_revive int(11) NOT NULL,
item_lucky_egg int(11) NOT NULL,
item_incense_ordinary int(11) NOT NULL,
item_incense_spicy int(11) NOT NULL,
item_incense_cool int(11) NOT NULL,
item_incense_floral int(11) NOT NULL,
item_troy_disk int(11) NOT NULL,
item_razz_berry int(11) NOT NULL,
item_bluk_berry int(11) NOT NULL,
item_nanab_berry int(11) NOT NULL,
item_wepar_berry int(11) NOT NULL,
item_pinap_berry int(11) NOT NULL,
item_incubator_basic int(11) NOT NULL,
item_incubator_basic_unlimited int(11) NOT NULL,
item_pokemon_storage_upgrade int(11) NOT NULL,
item_item_storage_upgrade int(11) NOT NULL,
PRIMARY KEY (id)

View File

@@ -19,8 +19,10 @@ import * as _player from "./player";
import * as _request from "./request";
import * as _response from "./response";
import * as _process from "./process";
import * as _mongo from "./db/mongo";
import * as _mysql from "./db/mysql";
import * as _mysql from "./db/index";
import * as _mysql_get from "./db/get";
import * as _mysql_query from "./db/query";
import * as _mysql_create from "./db/create";
const greetMessage = fs.readFileSync(".greet", "utf8");
@@ -44,6 +46,7 @@ class GameServer {
};
this.asset = null;
this.master = null;
this.socket = null;
this.cycleInstance = null;
@@ -118,11 +121,6 @@ class GameServer {
let name = String(CFG.DATABASE_TYPE).toUpperCase();
switch (name) {
case "MONGO":
case "MONGODB":
inherit(GameServer, _mongo);
this.setupConnection().then(resolve);
break;
case "MYSQL":
inherit(GameServer, _mysql);
this.setupConnection().then(resolve);
@@ -209,6 +207,15 @@ class GameServer {
}
}
fileExists(path) {
try {
fs.statSync(path);
} catch (e) {
return (false);
}
return (true);
}
greet() {
console.log(greetMessage);
}
@@ -221,6 +228,10 @@ inherit(GameServer, _player);
inherit(GameServer, _request);
inherit(GameServer, _response);
inherit(GameServer, _process);
inherit(GameServer, _mysql);
inherit(GameServer, _mysql_get);
inherit(GameServer, _mysql_query);
inherit(GameServer, _mysql_create);
let server = new GameServer();

View File

@@ -1,16 +1,17 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @return {Object}
*/
export default function AuthTicket() {
return (
new proto.Networking.Envelopes.AuthTicket({
start: new Buffer(""),
expire_timestamp_ms: 9999999999999,
end: new Buffer("")
})
);
let buffer = ({
start: new Buffer(""),
"expire_timestamp_ms": new Date.getTime(),
end: new Buffer("")
});
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Envelopes.AuthTicket"));
}

View File

@@ -1,6 +1,7 @@
import CFG from "../../cfg";
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Object} obj
@@ -8,12 +9,13 @@ import proto from "../proto";
*/
export default function CheckAwardedBadges(obj) {
return (
new proto.Networking.Responses.CheckAwardedBadgesResponse({
success: true,
awarded_badges: [],
awarded_badge_levels: []
}).encode()
);
let buffer = {
"success": true,
"awarded_badges": [],
"awarded_badge_levels": [],
"$unknownFields": []
}
return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.CheckAwardedBadgesResponse");
}

View File

@@ -1,19 +1,19 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Request} req
* @param {Object} obj
* @return {Object}
*/
export default function DownloadRemoteConfigVersion(req) {
export default function DownloadRemoteConfigVersion(obj) {
let data = proto.Networking.Requests.Messages.DownloadRemoteConfigVersionMessage.decode(req.request_message.toBuffer());
let buffer = {
"result": "SUCCESS",
"item_templates_timestamp_ms": "1471650700946",
"asset_digest_timestamp_ms": "1467338276561000",
"$unknownFields": []
}
return (
new proto.Networking.Responses.DownloadRemoteConfigVersionResponse({
result: 1,
item_templates_timestamp_ms: 1468540960537,
asset_digest_timestamp_ms: 1468540960527
}).encode()
);
return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.DownloadRemoteConfigVersionResponse");
}

View File

@@ -1,55 +1,44 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
import CFG from "../../cfg";
/**
* @param {Request} req
* @return {Object}
* @return {Buffer}
*/
export default function DownloadSettings(req) {
export default function DownloadSettings() {
let data = proto.Networking.Requests.Messages.DownloadSettingsMessage.decode(req.request_message.toBuffer());
let buffer = ({
hash: "2788184af4004004d6ab0740f7632983332106f6",
settings: {
fort_settings: {
"interaction_range_meters": 40.25098039215686,
"max_total_deployed_pokemon": 10,
"max_player_deployed_pokemon": 1,
"deploy_stamina_multiplier": 8.062745098039215,
"deploy_attack_multiplier": 0,
"far_interaction_range_meters": 1000.0156862745098
},
map_settings: {
"pokemon_visible_range": 70.00196078431372,
"poke_nav_range_meters": 751.0156862745098,
"encounter_range_meters": 50.25098039215686,
"get_map_objects_min_refresh_seconds": 10.007843017578125,
"get_map_objects_max_refresh_seconds": 30.01568603515625,
"get_map_objects_min_distance_meters": 10.007843017578125,
"google_maps_api_key": CFG.GMAPS_KEY
},
inventory_settings: {
"max_pokemon": 1000,
"max_bag_items": 1000,
"base_pokemon": 250,
"base_bag_items": 350,
"base_eggs": 9
},
minimum_client_version: CFG.MINIMUM_CLIENT_VERSION
}
})
if (!data.hash.length) {
return (
new proto.Networking.Responses.DownloadSettingsResponse({
hash: "2788184af4004004d6ab0740f7632983332106f6",
settings: new proto.Settings.GlobalSettings({
fort_settings: new proto.Settings.FortSettings({
"interaction_range_meters": 40.25098039215686,
"max_total_deployed_pokemon": 10,
"max_player_deployed_pokemon": 1,
"deploy_stamina_multiplier": 8.062745098039215,
"deploy_attack_multiplier": 0,
"far_interaction_range_meters": 1000.0156862745098
}),
map_settings: new proto.Settings.MapSettings({
"pokemon_visible_range": 70.00196078431372,
"poke_nav_range_meters": 751.0156862745098,
"encounter_range_meters": 50.25098039215686,
"get_map_objects_min_refresh_seconds": 10.007843017578125,
"get_map_objects_max_refresh_seconds": 30.01568603515625,
"get_map_objects_min_distance_meters": 10.007843017578125,
"google_maps_api_key": CFG.GMAPS_KEY
}),
inventory_settings: new proto.Settings.InventorySettings({
"max_pokemon": 1000,
"max_bag_items": 1000,
"base_pokemon": 250,
"base_bag_items": 350,
"base_eggs": 9
}),
minimum_client_version: CFG.MINIMUM_CLIENT_VERSION
})
}).encode()
);
}
else {
return (
new proto.Networking.Responses.DownloadSettingsResponse({
hash: "2788184af4004004d6ab0740f7632983332106f6"
}).encode()
);
}
return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.DownloadSettingsResponse");
}

View File

@@ -1,6 +1,7 @@
import CFG from "../../cfg";
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
import { decodeLong } from "../utils";
@@ -9,71 +10,45 @@ import { decodeLong } from "../utils";
* @return {Object}
*/
export default function Encounter(req) {
let id = decodeLong({
"low": 0,
"high": 0,
"unsigned": true
console.log(req.encounter_id, req.player_latitude, req.player_longitude);
let buffer = ({
"wild_pokemon": {
"encounter_id": req.encounter_id,
"last_modified_timestamp_ms": new Date().getTime(),
"latitude": req.player_latitude,
"longitude": req.player_longitude,
"spawn_point_id": "87bdcd8ec57",
"pokemon_data": {
"pokemon_id": "MEWTWO",
"cp": 164,
"stamina": 38,
"stamina_max": 38,
"move_1": "TACKLE_FAST",
"move_2": "BODY_SLAM",
"height_m": 0.36679142713546753,
"weight_kg": 9.639217376708984,
"individual_attack": 15,
"individual_defense": 1,
"individual_stamina": 9,
"cp_multiplier": 0.3210875988006592
},
"time_till_hidden_ms": 857876
},
"status": "ENCOUNTER_SUCCESS",
"capture_probability": {
"pokeball_type": [
"ITEM_POKE_BALL",
"ITEM_GREAT_BALL",
"ITEM_ULTRA_BALL"
],
"capture_probability": {
"0": 0.49830639362335205,
"1": 0.6446487903594971,
"2": 0.7483035326004028
}
}
});
return (
new proto.Networking.Responses.EncounterResponse({
wild_pokemon: new proto.Map.Pokemon.WildPokemon({
encounter_id: decodeLong({
"low": -1477718883,
"high": -1178282273,
"unsigned": true
}),
last_modified_timestamp_ms: decodeLong({
"low": 2047340539,
"high": 342,
"unsigned": false
}),
latitude: 39.19071817474392,
longitude: -96.58505386390713,
spawn_point_id: "87bdcd8e959",
pokemon_data: new proto.Data.PokemonData({
id: id,
pokemon_id: 17,
cp: 48,
stamina: 22,
stamina_max: 22,
move_1: 210,
move_2: 45,
deployed_fort_id: "",
owner_name: "",
is_egg: false,
egg_km_walked_target: 0,
egg_km_walked_start: 0,
origin: 0,
height_m: 0.8371214866638184,
weight_kg: 19.039264678955078,
individual_attack: 6,
individual_defense: 12,
individual_stamina: 7,
cp_multiplier: 0.16639786958694458,
pokeball: 0,
captured_cell_id: id,
battles_attacked: 0,
battles_defended: 0,
egg_incubator_id: "",
creation_time_ms: id,
num_upgrades: 0,
additional_cp_multiplier: 0,
favorite: 0,
nickname: "",
from_fort: 0
}),
time_till_hidden_ms: 336009
}),
background: 0,
status: 1,
capture_probability: new proto.Data.Capture.CaptureProbability({
pokeball_type: [1, 2, 3],
capture_probability: [0.6009692549705505, 0.7479367256164551, 0.8407744765281677],
reticle_difficulty_scale: 0
})
}).encode()
);
return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.EncounterResponse");
}

View File

@@ -1,6 +1,7 @@
import CFG from "../../cfg";
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Request} req
@@ -8,32 +9,19 @@ import proto from "../proto";
*/
export default function FortDetails(req) {
let data = proto.Networking.Requests.Messages.FortDetailsMessage.decode(req.request_message.toBuffer());
let buffer = ({
"fort_id": req.fort_id,
"name": "POGOserver v0.3.5",
"image_urls": [
"http://thecatapi.com/api/images/get?format=src&type=png"
],
"type": "CHECKPOINT",
"latitude": req.latitude,
"longitude": req.longitude,
"modifiers": [],
"$unknownFields": []
});
return (
new proto.Networking.Responses.FortDetailsResponse({
"fort_id": data.fort_id,
"team_color": 0,
"pokemon_data": null,
"name": "POGOserver v0.2.0",
"description": "Weird species below",
"image_urls": [
"http://thecatapi.com/api/images/get?format=src&type=png"
],
"fp": 0,
"stamina": 0,
"max_stamina": 0,
"type": 1,
"latitude": data.latitude,
"longitude": data.longitude,
"modifiers": [
new proto.Map.Fort.FortModifier({
item_id: proto.Inventory.Item.ItemId.ITEM_TROY_DISK,
expiration_timestamp_ms: (new Date().getTime() + 1e3) * 1e3,
deployer_player_codename: "The Big Lebowski"
})
]
}).encode()
);
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.FortDetailsResponse"));
}

View File

@@ -1,6 +1,7 @@
import CFG from "../../cfg";
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Object} obj
@@ -8,25 +9,26 @@ import proto from "../proto";
*/
export default function FortSearch(obj) {
return (
new proto.Networking.Responses.FortSearchResponse({
result: proto.Networking.Responses.FortSearchResponse.Result.SUCCESS,
items_awarded: [
new proto.Inventory.Item.ItemAward({
item_id: proto.Inventory.Item.ItemId.ITEM_MASTER_BALL,
item_count: 3
}),
new proto.Inventory.Item.ItemAward({
item_id: proto.Inventory.Item.ItemId.ITEM_ULTRA_BALL,
item_count: 2
})
],
gems_awarded: 0,
pokemon_data_egg: null,
experience_awarded: 99999,
cooldown_complete_timestamp_ms: 1470174535972,
chain_hack_sequence_number: 0
}).encode()
);
let ii = 0;
let amount = 5;
let items = [];
while (++ii < amount) {
items.push({
"item_id": "ITEM_MASTER_BALL",
"item_count": 1
})
};
let buffer = ({
"result": "SUCCESS",
"items_awarded": items,
"experience_awarded": 50,
"cooldown_complete_timestamp_ms": "1471780158665",
"chain_hack_sequence_number": 2,
"$unknownFields": []
});
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.FortSearchResponse"));
}

View File

@@ -8,7 +8,5 @@ import CFG from "../../cfg";
* @return {Object}
*/
export default function GetAssetDigest(req) {
return (fs.readFileSync("data/asset_digest"));
}

View File

@@ -1,6 +1,5 @@
import proto from "../proto";
import DownloadUrlEntry from "./Data.DownloadUrlEntry";
import POGOProtos from "pokemongo-protobuf";
import CFG from "../../cfg";
@@ -13,9 +12,7 @@ import {
*/
export default function GetDownloadUrls(asset, ip, req) {
let data = proto.Networking.Requests.Messages.GetDownloadUrlsMessage.decode(req.request_message.toBuffer());
let key = data.asset_id[0];
let key = req.asset_id[0];
let download_urls = [];
@@ -29,19 +26,17 @@ export default function GetDownloadUrls(asset, ip, req) {
return new Promise((resolve) => {
download_urls.push(
new proto.Data.DownloadUrlEntry({
{
asset_id: key,
url: `http://${ip}:${CFG.PORT}/model/${node.bundle_name}`,
size: node.size,
checksum: node.checksum
})
}
);
let output = (
new proto.Networking.Responses.GetDownloadUrlsResponse({
download_urls: download_urls
}).encode()
);
resolve(output);
let buffer = ({
download_urls: download_urls
});
resolve(POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetDownloadUrlsResponse"));
});
}

View File

@@ -1,4 +1,5 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Object} obj
@@ -6,14 +7,15 @@ import proto from "../proto";
*/
export default function GetHatchedEggs(obj) {
return (
new proto.Networking.Responses.GetHatchedEggsResponse({
success: true,
pokemon_id: [],
experience_awarded: [],
candy_awarded: [],
stardust_awarded: []
}).encode()
);
let buffer = {
"success": true,
"pokemon_id": [],
"experience_awarded": [],
"candy_awarded": [],
"stardust_awarded": [],
"$unknownFields": []
};
return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetHatchedEggsResponse");
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Object} obj
@@ -7,20 +8,20 @@ import proto from "../proto";
function getPlayerDataPacket(obj) {
return (
new proto.Data.PlayerData({
{
creation_timestamp_ms: 1467936859925,
username: obj.username,
team: proto.Enums.TeamColor.YELLOW,
tutorial_state: obj.tutorial_state,
avatar: new proto.Data.Player.PlayerAvatar(obj.avatar),
avatar: obj.avatar,
max_pokemon_storage: 250,
max_item_storage: 350,
daily_bonus: new proto.Data.Player.DailyBonus({
daily_bonus: {
next_defender_bonus_collect_timestamp_ms: 1470174535972
}),
contact_settings: new proto.Data.Player.ContactSettings(obj.contact_settings),
},
contact_settings: obj.contact_settings,
currencies: obj.currencies
})
}
);
}
@@ -63,14 +64,14 @@ function buildPlayerData(obj) {
];
let currencies = [
new proto.Data.Player.Currency({
{
name: "POKECOIN",
amount: pokecoins
}),
new proto.Data.Player.Currency({
},
{
name: "STARDUST",
amount: stardust
})
}
];
return ({
@@ -91,14 +92,43 @@ function buildPlayerData(obj) {
export default function GetPlayer(obj) {
let data = buildPlayerData(obj);
let packet = getPlayerDataPacket(data);
return (
new proto.Networking.Responses.GetPlayerResponse({
success: true,
player_data: packet
})
);
let buffer = {
"success": true,
"player_data": {
"creation_timestamp_ms": "1471096437979",
"username": "Administrator",
"team": "YELLOW",
"tutorial_state": [
"LEGAL_SCREEN",
"AVATAR_SELECTION",
"POKEMON_CAPTURE",
"NAME_SELECTION",
"FIRST_TIME_EXPERIENCE_COMPLETE"
],
"avatar": {},
"max_pokemon_storage": 250,
"max_item_storage": 350,
"daily_bonus": {},
"equipped_badge": {},
"contact_settings": {
"send_marketing_emails": true
},
"currencies": [
{
"name": "POKECOIN",
"amount": 1339
},
{
"name": "STARDUST",
"amount": 7681
}
]
},
"$unknownFields": []
};
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetPlayerResponse"));
}

View File

@@ -1,4 +1,5 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Object} obj
@@ -6,216 +7,162 @@ import proto from "../proto";
*/
export default function GetPlayerProfile(obj) {
return (
new proto.Networking.Responses.GetPlayerProfileResponse({
result: proto.Networking.Responses.GetPlayerProfileResponse.Result.SUCCESS,
start_time: new Date().getTime() * 1000,
badges: [
new proto.Data.PlayerBadge({
"badge_type": 1,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 1.0598372225667916
}),
new proto.Data.PlayerBadge({
"badge_type": 2,
"rank": 1,
"start_value": 5,
"end_value": 50,
"current_value": 5.031372549019608
}),
new proto.Data.PlayerBadge({
"badge_type": 3,
"rank": 0,
"start_value": 0,
"end_value": 30,
"current_value": 5.031372549019608
}),
new proto.Data.PlayerBadge({
"badge_type": 5,
"rank": 0,
"start_value": 0,
"end_value": 3,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 6,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 8,
"rank": 0,
"start_value": 0,
"end_value": 100,
"current_value": 37.00098039215686
}),
new proto.Data.PlayerBadge({
"badge_type": 11,
"rank": 0,
"start_value": 0,
"end_value": 3,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 13,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 14,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 18,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 8.062745098039215
}),
new proto.Data.PlayerBadge({
"badge_type": 19,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 20,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 8.062745098039215
}),
new proto.Data.PlayerBadge({
"badge_type": 21,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 1.007843137254902
}),
new proto.Data.PlayerBadge({
"badge_type": 22,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 23,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 24,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 8.062745098039215
}),
new proto.Data.PlayerBadge({
"badge_type": 25,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 26,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 27,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 28,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 29,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 30,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 31,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 32,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 33,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 34,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 35,
"rank": 0,
"start_value": 0,
"end_value": 10,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 36,
"rank": 0,
"start_value": 0,
"end_value": 3,
"current_value": 0
}),
new proto.Data.PlayerBadge({
"badge_type": 37,
"rank": 0,
"start_value": 0,
"end_value": 3,
"current_value": 0
})
]
}).encode()
);
let buffer = ({
"result": "SUCCESS",
"start_time": "1471096437979",
"badges": [
{
"badge_type": "BADGE_TRAVEL_KM",
"end_value": 10,
"current_value": 3.921541213989258
},
{
"badge_type": "BADGE_POKEDEX_ENTRIES",
"rank": 1,
"start_value": 5,
"end_value": 50,
"current_value": 25
},
{
"badge_type": "BADGE_CAPTURE_TOTAL",
"rank": 1,
"start_value": 30,
"end_value": 500,
"current_value": 71
},
{
"badge_type": "BADGE_EVOLVED_TOTAL",
"end_value": 3
},
{
"badge_type": "BADGE_HATCHED_TOTAL",
"end_value": 10,
"current_value": 1
},
{
"badge_type": "BADGE_POKESTOPS_VISITED",
"rank": 1,
"start_value": 100,
"end_value": 1000,
"current_value": 123
},
{
"badge_type": "BADGE_BIG_MAGIKARP",
"end_value": 3,
"current_value": 1
},
{
"badge_type": "BADGE_BATTLE_ATTACK_WON",
"end_value": 10
},
{
"badge_type": "BADGE_BATTLE_TRAINING_WON",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_NORMAL",
"rank": 1,
"start_value": 10,
"end_value": 50,
"current_value": 24
},
{
"badge_type": "BADGE_TYPE_FIGHTING",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_FLYING",
"rank": 1,
"start_value": 10,
"end_value": 50,
"current_value": 26
},
{
"badge_type": "BADGE_TYPE_POISON",
"rank": 1,
"start_value": 10,
"end_value": 50,
"current_value": 20
},
{
"badge_type": "BADGE_TYPE_GROUND",
"end_value": 10,
"current_value": 1
},
{
"badge_type": "BADGE_TYPE_ROCK",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_BUG",
"rank": 1,
"start_value": 10,
"end_value": 50,
"current_value": 14
},
{
"badge_type": "BADGE_TYPE_GHOST",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_STEEL",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_FIRE",
"end_value": 10,
"current_value": 1
},
{
"badge_type": "BADGE_TYPE_WATER",
"rank": 1,
"start_value": 10,
"end_value": 50,
"current_value": 14
},
{
"badge_type": "BADGE_TYPE_GRASS",
"end_value": 10,
"current_value": 3
},
{
"badge_type": "BADGE_TYPE_ELECTRIC",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_PSYCHIC",
"end_value": 10,
"current_value": 1
},
{
"badge_type": "BADGE_TYPE_ICE",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_DRAGON",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_DARK",
"end_value": 10
},
{
"badge_type": "BADGE_TYPE_FAIRY",
"end_value": 10,
"current_value": 3
},
{
"badge_type": "BADGE_SMALL_RATTATA",
"end_value": 3
},
{
"badge_type": "BADGE_PIKACHU",
"end_value": 3
}
],
"$unknownFields": []
});
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetPlayerProfileResponse"));
}

View File

@@ -1,87 +1,12 @@
import CFG from "../../cfg";
import fs from "fs";
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Object} obj
* @return {Object}
*/
export default function ItemTemplates(obj) {
return (
new proto.Networking.Responses.DownloadItemTemplatesResponse({
success: true,
item_templates: new proto.Networking.Responses.DownloadItemTemplatesResponse.ItemTemplate({
pokemon_settings: null,
item_settings: null,
move_settings: null,
move_sequence_settings: null,
camera: null,
iap_item_display: null,
equipped_badges: null,
type_effective: new proto.Settings.Master.TypeEffectiveSettings({
"attack_scalar": [1, 0.800000011920929, 0.800000011920929, 0.800000011920929, 1, 1, 1, 0.800000011920929, 0.800000011920929, 0.800000011920929, 1, 1.25, 1, 1.25, 1, 1, 1.25, 0.800000011920929],
"attack_type": 7
}),
badge_settings: new proto.Settings.Master.BadgeSettings({
"badge_type": 13,
"badge_rank": 4,
"targets": [10, 100, 1000]
}),
player_level: new proto.Settings.Master.PlayerLevelSettings({
"rank_num": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"required_experience": [0, 1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000, 65000, 75000, 85000, 100000, 120000, 140000, 160000, 185000, 210000, 260000, 335000, 435000, 560000, 710000, 900000, 1100000, 1350000, 1650000, 2000000, 2500000, 3000000, 3750000, 4750000, 6000000, 7500000, 9500000, 12000000, 15000000, 20000000],
"cp_multiplier": [0.09399999678134918, 0.16639786958694458, 0.21573247015476227, 0.2557200491428375, 0.29024988412857056, 0.3210875988006592, 0.3492126762866974, 0.37523558735847473, 0.39956727623939514, 0.42250001430511475, 0.443107545375824, 0.4627983868122101, 0.48168495297431946, 0.49985843896865845, 0.517393946647644, 0.5343543291091919, 0.5507926940917969, 0.5667545199394226, 0.5822789072990417, 0.5974000096321106, 0.6121572852134705, 0.6265671253204346, 0.6406529545783997, 0.6544356346130371, 0.667934000492096, 0.6811649203300476, 0.6941436529159546, 0.7068842053413391, 0.719399094581604, 0.7317000031471252, 0.7377694845199585, 0.7437894344329834, 0.7497610449790955, 0.7556855082511902, 0.7615638375282288, 0.7673971652984619, 0.7731865048408508, 0.7789327502250671, 0.7846369743347168, 0.7903000116348267],
"max_egg_player_level": 20,
"max_encounter_player_level": 30
}),
gym_level: new proto.Settings.Master.GymLevelSettings({
"required_experience": [0, 2000, 4000, 8000, 12000, 16000, 20000, 30000, 40000, 50000],
"leader_slots": [1, 1, 1, 2, 2, 2, 3, 3, 3, 4],
"trainer_slots": [0, 1, 2, 2, 3, 4, 4, 5, 6, 6],
"search_roll_bonus": []
}),
battle_settings: new proto.Settings.Master.GymBattleSettings({
"energy_per_sec": 0,
"dodge_energy_cost": 0,
"retarget_seconds": 0.5,
"enemy_attack_interval": 1.5,
"attack_server_interval": 5,
"round_duration_seconds": 99,
"bonus_time_per_ally_seconds": 10,
"maximum_attackers_per_battle": 20,
"same_type_attack_bonus_multiplier": 1.25,
"maximum_energy": 100,
"energy_delta_per_health_lost": 0.5,
"dodge_duration_ms": 500,
"minimum_player_level": 5,
"swap_duration_ms": 1000
}),
encounter_settings: new proto.Settings.Master.EncounterSettings({
"spin_bonus_threshold": 0.5,
"excellent_throw_threshold": 1.7000000476837158,
"great_throw_threshold": 1.2999999523162842,
"nice_throw_threshold": 1,
"milestone_threshold": 100
}),
iap_settings: new proto.Settings.Master.IapSettings({
"daily_bonus_coins": 0,
"daily_defender_bonus_per_pokemon": [500, 10],
"daily_defender_bonus_max_defenders": 10,
"daily_defender_bonus_currency": ["STARDUST", "POKECOIN"],
"min_time_between_claims_ms": 0,
"daily_bonus_enabled": false,
"daily_defender_bonus_enabled": true
}),
pokemon_upgrades: new proto.Settings.Master.PokemonUpgradeSettings({
"upgrades_per_level": 2,
"allowed_levels_above_player": 2,
"candy_cost": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 15, 15],
"stardust_cost": [200, 200, 400, 400, 600, 600, 800, 800, 1000, 1000, 1300, 1300, 1600, 1600, 1900, 1900, 2200, 2200, 2500, 2500, 3000, 3000, 3500, 3500, 4000, 4000, 4500, 4500, 5000, 5000, 6000, 6000, 7000, 7000, 8000, 8000, 9000, 9000, 10000, 10000]
})
}),
timestamp_ms: 1468540960537
}).encode()
);
export default function ItemTemplates() {
return (fs.readFileSync("data/game_master"));
}

View File

@@ -1,4 +1,5 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
import { GetPlayer } from "./";
@@ -8,12 +9,13 @@ import { GetPlayer } from "./";
*/
export default function LevelUpRewards(obj) {
return (
new proto.Networking.Responses.LevelUpRewardsResponse({
result: 2,
items_awarded: [],
items_unlocked: []
}).encode()
);
let buffer = {
"result": "AWARDED_ALREADY",
"items_awarded": [],
"items_unlocked": [],
"$unknownFields": []
}
return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.LevelUpRewardsResponse");
}

View File

@@ -1,4 +1,5 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
import { GetPlayer } from "./";
@@ -8,11 +9,11 @@ import { GetPlayer } from "./";
*/
export default function SetAvatar(player) {
return (
new proto.Networking.Responses.SetAvatarResponse({
status: proto.Networking.Responses.SetAvatarResponse.Status.SUCCESS,
player_data: GetPlayer(player).player_data
}).encode()
);
let buffer = ({
status: proto.Networking.Responses.SetAvatarResponse.Status.SUCCESS,
player_data: GetPlayer(player).player_data
});
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.SetAvatarResponse"));
}

View File

@@ -1,6 +1,7 @@
import CFG from "../../cfg";
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
/**
* @param {Request} req
@@ -8,14 +9,12 @@ import proto from "../proto";
*/
export default function SetFavoritePokemon(req) {
let data = proto.Networking.Requests.Messages.SetFavoritePokemonMessage.decode(req.request_message.toBuffer());
console.log(data);
// TODO: save into db
buffer = ({
result: proto.Networking.Responses.SetFavoritePokemonResponse.Result.ERROR_POKEMON_NOT_FOUND
});
return (
new proto.Networking.Responses.SetFavoritePokemonResponse({
result: proto.Networking.Responses.SetFavoritePokemonResponse.Result.ERROR_POKEMON_NOT_FOUND
}).encode()
POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.SetFavoritePokemonResponse")
);
}

View File

@@ -1,4 +1,5 @@
import proto from "../proto";
import POGOProtos from "pokemongo-protobuf";
import CFG from "../../cfg";
@@ -8,50 +9,642 @@ import CFG from "../../cfg";
*/
export default function SfidaActionLog(obj) {
return (
new proto.Networking.Responses.SfidaActionLogResponse({
result: proto.Networking.Responses.SfidaActionLogResponse.Result.SUCCESS,
log_entries: [
new proto.Data.Logs.ActionLogEntry({
timestamp_ms: (new Date().getTime() - 1e4) * 1e3,
sfida: false,
catch_pokemon: null,
fort_search: new proto.Data.Logs.FortSearchLogEntry({
result: proto.Data.Logs.FortSearchLogEntry.Result.SUCCESS,
fort_id: "",
items: [
new proto.Inventory.Item.ItemData({
item_id: proto.Inventory.Item.ItemId.ITEM_MASTER_BALL,
count: 2,
unseen: false
}),
new proto.Inventory.Item.ItemData({
item_id: proto.Inventory.Item.ItemId.ITEM_ULTRA_BALL,
count: 2,
unseen: false
})
]
})
})
/*,
new proto.Data.Logs.ActionLogEntry({
timestamp_ms: (new Date().getTime() - 1e3) * 1e3,
catch_pokemon: new proto.Data.Logs.CatchPokemonLogEntry({
result: proto.Data.Logs.CatchPokemonLogEntry.Result.SUCCESS,
pokemon_id: proto.Enums.PokemonId.PIDGEY,
combat_points: 352
})
}),
new proto.Data.Logs.ActionLogEntry({
timestamp_ms: (new Date().getTime() - 1e2) * 1e3,
catch_pokemon: new proto.Data.Logs.CatchPokemonLogEntry({
result: proto.Data.Logs.CatchPokemonLogEntry.Result.SUCCESS,
pokemon_id: proto.Enums.PokemonId.CHARIZARD,
combat_points: 963
})
})*/
]
}).encode()
);
let buffer = ({
"result": "SUCCESS",
"log_entries": [
{
"timestamp_ms": "1471694560585",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "HORSEA",
"combat_points": 110
}
},
{
"timestamp_ms": "1471694566830",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "HORSEA",
"combat_points": 73
}
},
{
"timestamp_ms": "1471694573468",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471694597662",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "HORSEA",
"combat_points": 102
}
},
{
"timestamp_ms": "1471694603880",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "CATERPIE",
"combat_points": 36
}
},
{
"timestamp_ms": "1471694610259",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "WEEDLE",
"combat_points": 15
}
},
{
"timestamp_ms": "1471694616586",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "PIDGEY",
"combat_points": 26
}
},
{
"timestamp_ms": "1471694632969",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 1
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471694739319",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471694741772",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 4
}
]
}
},
{
"timestamp_ms": "1471694904167",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "KRABBY",
"combat_points": 100
}
},
{
"timestamp_ms": "1471694925722",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 2
},
{
"item_id": "ITEM_POKE_BALL",
"count": 4
}
]
}
},
{
"timestamp_ms": "1471695030964",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471695071016",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695089887",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "SPEAROW",
"combat_points": 80
}
},
{
"timestamp_ms": "1471695096341",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471695139926",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "EKANS",
"combat_points": 72
}
},
{
"timestamp_ms": "1471695148440",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695195481",
"catch_pokemon": {
"result": "UNKNOWN_ENUM_VALUE_Result_3",
"pokemon_id": "MAGIKARP",
"combat_points": 26
}
},
{
"timestamp_ms": "1471695197676",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "ZUBAT",
"combat_points": 41
}
},
{
"timestamp_ms": "1471695203917",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "MAGIKARP",
"combat_points": 46
}
},
{
"timestamp_ms": "1471695211919",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471695316895",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "ZUBAT",
"combat_points": 43
}
},
{
"timestamp_ms": "1471695323589",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471695429795",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 1
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695487237",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471695522740",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471695577816",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 1
},
{
"item_id": "ITEM_POTION",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471695633092",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 1
},
{
"item_id": "ITEM_POTION",
"count": 2
}
],
"eggs": 1
}
},
{
"timestamp_ms": "1471695738726",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471695776746",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_REVIVE",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695790415",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_REVIVE",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 4
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695829422",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "MAGIKARP",
"combat_points": 40
}
},
{
"timestamp_ms": "1471695836445",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695838748",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695860629",
"catch_pokemon": {
"result": "POKEMON_FLED",
"pokemon_id": "VENONAT",
"combat_points": 174
}
},
{
"timestamp_ms": "1471695866223",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471695884419",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "STARYU",
"combat_points": 11
}
},
{
"timestamp_ms": "1471695889856",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471695906137",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "PINSIR",
"combat_points": 28
}
},
{
"timestamp_ms": "1471695914356",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471696008778",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471696010713",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "CATERPIE",
"combat_points": 74
}
},
{
"timestamp_ms": "1471696050313",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471696052566",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
},
{
"timestamp_ms": "1471696072147",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 1
},
{
"item_id": "ITEM_POTION",
"count": 2
}
]
}
},
{
"timestamp_ms": "1471696074058",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "ZUBAT",
"combat_points": 40
}
},
{
"timestamp_ms": "1471696079308",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_RAZZ_BERRY",
"count": 1
},
{
"item_id": "ITEM_POKE_BALL",
"count": 2
},
{
"item_id": "ITEM_POTION",
"count": 1
}
]
}
},
{
"timestamp_ms": "1471696081215",
"catch_pokemon": {
"result": "POKEMON_CAPTURED",
"pokemon_id": "ZUBAT",
"combat_points": 73
}
},
{
"timestamp_ms": "1471696235352",
"fort_search": {
"result": "SUCCESS",
"items": [
{
"item_id": "ITEM_POKE_BALL",
"count": 3
}
]
}
}
],
"$unknownFields": []
});
return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.SfidaActionLogResponse"));
}

View File

@@ -113,33 +113,28 @@ class Player {
}
/**
* @param {Request} req
* @param {Object} obj
*/
updatePosition(req) {
let data = decodeRequestEnvelope(req.request_message.buffer);
this.latitude = data.latitude;
this.longitude = data.longitude;
this.altitude = data.altitude;
updatePosition(obj) {
this.latitude = obj.latitude;
this.longitude = obj.longitude;
}
updateAvatar(req) {
let data = proto.Networking.Requests.Messages.SetAvatarMessage.decode(req.request_message.toBuffer()).player_avatar;
let node = null;
if (!data) return void 0;
this.skin = data.skin;
this.hair = data.hair;
this.shirt = data.shirt;
this.pants = data.pants;
this.hat = data.hat;
this.shoes = data.shoes;
this.eyes = data.eyes;
this.gender = data.gender;
this.backpack = data.backpack;
for (let key in req.player_avatar) {
node = req.player_avatar[key];
if (key === "gender") {
this.gender = node === "FEMALE" ? 1 : 0;
}
else {
if (this.hasOwnProperty(key)) {
this[key] = node;
}
}
};
}
@@ -345,7 +340,7 @@ export function loginPlayer(player) {
return new Promise((resolve) => {
this.getUserByEmail(player.email).then((doc) => {
player.updateByObject(doc);
let buffer = GetPlayer(player).encode();
let buffer = GetPlayer(player);
resolve(buffer);
});
});
@@ -409,9 +404,13 @@ export function authenticatePlayer(player) {
else if (token.provider === "ptc") {
let decoded = token.token.contents;
player.isPTCAccount = true;
this.print("PTC auth isnt supported yet! Kicking..", 31);
this.removePlayer(player);
return void 0;
player.email = decoded.split("-")[1];
player.email_verified = true;
player.isPTCAccount = true;
//console.log(decoded);
this.print("PTC auth isnt supported yet! Your progress wont get saved!", 33);
//this.removePlayer(player);
//return void 0;
}
else {
this.print("Invalid provider! Kicking..", 31);

View File

@@ -1,6 +1,8 @@
import fs from "fs";
import url from "url";
import proto from "./proto";
import pcrypt from "pcrypt";
import POGOProtos from "pokemongo-protobuf";
import CFG from "../cfg";
@@ -66,6 +68,24 @@ export function getRequestType(req) {
}
export function parseProtobuf(buffer, path) {
try {
return POGOProtos.parseWithUnknown(buffer, path);
} catch (e) {
this.print(e, 31);
}
}
/**
* @param {Request} req
*/
export function parseSignature(req) {
let key = pcrypt.decrypt(req.unknown6.unknown2.encrypted_signature);
return (
POGOProtos.parseWithUnknown(key, "POGOProtos.Networking.Envelopes.Signature")
);
}
/**
* @param {Request} req
*/
@@ -82,7 +102,7 @@ export function onRequest(req) {
}
}
let request = proto.Networking.Envelopes.RequestEnvelope.decode(req.body);
let request = this.parseProtobuf(req.body, "POGOProtos.Networking.Envelopes.RequestEnvelope");
if (!request.requests.length) {
this.print("Received invalid request!", 31);
@@ -92,7 +112,7 @@ export function onRequest(req) {
if (CFG.DEBUG_LOG_REQUESTS) {
console.log("#####");
request.requests.map((request) => {
console.log("Got request:", this.getRequestType(request));
console.log("Got request:", request.request_type);
}).join(",");
}
@@ -102,7 +122,7 @@ export function onRequest(req) {
}
this.processRequests(player, request.requests).then((answer) => {
let msg = this.envelopResponse(1, request.request_id, answer, !!request.auth_ticket);
let msg = this.envelopResponse(1, request.request_id, answer, !!request.auth_ticket, request);
if (CFG.DEBUG_DUMP_TRAFFIC) {
this.dumpTraffic(req.body, msg);
}
@@ -118,17 +138,19 @@ export function onRequest(req) {
* @param {Boolean} auth
* @return {Buffer}
*/
export function envelopResponse(status, id, response, auth) {
export function envelopResponse(status, id, response, auth, req) {
let answer = ResponseEnvelope({
id: id,
status: status,
response: response
});
let buffer = req;
if (auth) answer.auth_ticket = AuthTicket();
delete buffer.requests;
return (answer);
buffer.returns = response;
buffer.status_code = 1;
return (
POGOProtos.serialize(buffer, "POGOProtos.Networking.Envelopes.ResponseEnvelope")
);
}

View File

@@ -8,7 +8,6 @@ import {
CheckAwardedBadges,
DownloadSettings,
DownloadRemoteConfigVersion,
GetPlayer,
GetPlayerProfile,
ItemTemplates,
GetAssetDigest,
@@ -29,6 +28,8 @@ import {
ClaimCodeName
} from "./packets";
import { _toCC } from "./utils";
const REQUEST = proto.Networking.Requests.RequestType;
/**
@@ -40,119 +41,127 @@ export function processResponse(player, req) {
let buffer = null;
let cc = _toCC(req.request_type);
let msg = null;
let proto = `POGOProtos.Networking.Requests.Messages.${cc}Message`;
if (req.request_message) {
try {
msg = this.parseProtobuf(req.request_message, proto);
} catch (e) {
this.print(`Failed to parse ${cc}: ${e}`, 31);
}
}
return new Promise((resolve) => {
try {
switch (req.request_type) {
case REQUEST.GET_PLAYER:
case "GET_PLAYER":
this.forwardPlayer(player).then((res) => resolve(res));
return void 0;
break;
case REQUEST.GET_HATCHED_EGGS:
case "GET_HATCHED_EGGS":
buffer = GetHatchedEggs();
break;
case REQUEST.GET_INVENTORY:
buffer = GetInventory();
case "GET_INVENTORY":
buffer = GetInventory(msg);
break;
case REQUEST.CHECK_AWARDED_BADGES:
case "CHECK_AWARDED_BADGES":
buffer = CheckAwardedBadges();
break;
case REQUEST.DOWNLOAD_SETTINGS:
buffer = DownloadSettings(req);
case "DOWNLOAD_SETTINGS":
buffer = DownloadSettings();
break;
case REQUEST.DOWNLOAD_ITEM_TEMPLATES:
case "DOWNLOAD_ITEM_TEMPLATES":
buffer = ItemTemplates();
break;
case REQUEST.DOWNLOAD_REMOTE_CONFIG_VERSION:
buffer = DownloadRemoteConfigVersion(req);
case "DOWNLOAD_REMOTE_CONFIG_VERSION":
buffer = DownloadRemoteConfigVersion(msg);
break;
case REQUEST.GET_ASSET_DIGEST:
buffer = GetAssetDigest(req);
case "GET_ASSET_DIGEST":
buffer = GetAssetDigest(msg);
break;
case REQUEST.GET_PLAYER_PROFILE:
case "GET_PLAYER_PROFILE":
buffer = GetPlayerProfile();
break;
case REQUEST.GET_MAP_OBJECTS:
player.updatePosition(req);
buffer = GetMapObjects(player, req);
case "GET_MAP_OBJECTS":
player.updatePosition(msg);
buffer = GetMapObjects(player, msg);
this.savePlayer(player).then(() => {
resolve(buffer);
});
return void 0;
break;
case REQUEST.GET_DOWNLOAD_URLS:
GetDownloadUrls(this.asset, this.getLocalIPv4(), req).then((res) => {
case "GET_DOWNLOAD_URLS":
GetDownloadUrls(this.asset, this.getLocalIPv4(), msg).then((res) => {
resolve(res);
});
return void 0;
break;
case REQUEST.SET_AVATAR:
player.updateAvatar(req);
case "SET_AVATAR":
player.updateAvatar(msg);
buffer = SetAvatar(player);
this.savePlayer(player).then(() => {
resolve(buffer);
});
return void 0;
break;
case REQUEST.SFIDA_ACTION_LOG:
case "SFIDA_ACTION_LOG":
buffer = SfidaActionLog();
break;
case REQUEST.MARK_TUTORIAL_COMPLETE:
case "MARK_TUTORIAL_COMPLETE":
buffer = MarkTutorialComplete(player);
this.savePlayer(player).then(() => {
resolve(buffer);
});
return void 0;
break;
case REQUEST.CLAIM_CODENAME:
buffer = ClaimCodeName(req, player);
case "CLAIM_CODENAME":
buffer = ClaimCodeName(msg, player);
this.savePlayer(player).then(() => {
resolve(buffer);
});
return void 0;
break;
case REQUEST.LEVEL_UP_REWARDS:
case "LEVEL_UP_REWARDS":
buffer = LevelUpRewards();
break;
case REQUEST.FORT_DETAILS:
buffer = FortDetails(req);
case "FORT_DETAILS":
buffer = FortDetails(msg);
break;
case REQUEST.FORT_SEARCH:
case "FORT_SEARCH":
buffer = FortSearch();
break;
case REQUEST.SET_CONTACT_SETTINGS:
player.updateContactSettings(req);
case "SET_CONTACT_SETTINGS":
player.updateContactSettings(msg);
buffer = SetContactSettings(player);
this.savePlayer(player).then(() => {
resolve(buffer);
});
return void 0;
break;
case REQUEST.ENCOUNTER:
buffer = Encounter(req);
case "ENCOUNTER":
buffer = Encounter(msg);
break;
case REQUEST.NICKNAME_POKEMON:
buffer = NicknamePokemon(req);
case "NICKNAME_POKEMON":
buffer = NicknamePokemon(msg);
break;
case REQUEST.UPGRADE_POKEMON:
buffer = UpgradePokemon(req);
case "UPGRADE_POKEMON":
buffer = UpgradePokemon(msg);
break;
case REQUEST.EVOLVE_POKEMON:
buffer = EvolvePokemon(req);
case "EVOLVE_POKEMON":
buffer = EvolvePokemon(msg);
break;
case REQUEST.SET_FAVORITE_POKEMON:
buffer = SetFavoritePokemon(req);
break;
case REQUEST.CATCH_POKEMON:
let data = proto.Networking.Requests.Messages.CatchPokemonMessage.decode(req.request_message.toBuffer());
console.log(data);
case "SET_FAVORITE_POKEMON":
buffer = SetFavoritePokemon(msg);
break;
default:
this.print(`Unknown request: ${this.getRequestType(req)}`, 31);
this.print(`Unknown request: ${req.request_type}`, 31);
break;
};
} catch (e) {
console.log(e);
this.print(`Response error: ${e}`, 31);
};
resolve(buffer);

View File

@@ -5,6 +5,8 @@ import proto from "./proto";
import CFG from "../cfg";
import { idToPkmnBundleName } from "./utils";
export function setup() {
let isFirstRun = !this.directoryExists(CFG.DUMP_ASSET_PATH);
@@ -19,17 +21,63 @@ export function setup() {
return void 0;
}
this.asset = this.parseAssetDigest();
// make sure all assets got loaded properly
this.validateAssets().then(() => {
this.setupDatabaseConnection().then(() => {
if (CFG.PORT < 1) {
this.print("Invalid port!", 31);
return void 0;
this.print(`Downloaded assets are valid! Proceeding..`);
this.asset = this.parseAssetDigest();
this.master = this.parseGameMaster();
this.setupDatabaseConnection().then(() => {
if (CFG.PORT < 1) {
this.print("Invalid port!", 31);
return void 0;
}
this.socket = this.createHTTPServer();
setTimeout(this::this.cycle, 1);
let localIPv4 = this.getLocalIPv4();
this.print(`Server running at ${localIPv4}:${CFG.PORT}`);
});
}).catch((e) => {
//fse.removeSync(CFG.DUMP_ASSET_PATH);
this.print("Error: " + e + " was not found!", 31);
});
}
/**
* Make sure all required
* assets got loaded properly
*/
export function validateAssets() {
let index = 0;
let max = CFG.MAX_POKEMON_NATIONAL_ID;
return new Promise((resolve, reject) => {
// validate asset digest
if (!this.fileExists(CFG.DUMP_ASSET_PATH + "asset_digest")) {
return reject("File asset_digest");
}
this.socket = this.createHTTPServer();
setTimeout(this::this.cycle, 1);
let localIPv4 = this.getLocalIPv4();
this.print(`Server running at ${localIPv4}:${CFG.PORT}`);
// validate game master
if (!this.fileExists(CFG.DUMP_ASSET_PATH + "game_master")) {
return reject("File game_master");
}
// validate models
while (++index <= max) {
let id = idToPkmnBundleName(index);
if (!this.fileExists(CFG.DUMP_ASSET_PATH + id)) {
return reject("Model " + id);
}
};
resolve();
});
}
@@ -37,26 +85,42 @@ export function setup() {
export function parseAssetDigest() {
let asset = null;
try {
asset = proto.Networking.Responses.GetAssetDigestResponse.decode(fs.readFileSync(CFG.DUMP_ASSET_PATH + "asset_digest"));
let data = fs.readFileSync(CFG.DUMP_ASSET_PATH + "asset_digest");
asset = this.parseProtobuf(data, "POGOProtos.Networking.Responses.GetAssetDigestResponse");
} catch (e) {
this.print(e, 31);
}
return (asset);
}
export function parseGameMaster() {
let master = null;
try {
let data = fs.readFileSync(CFG.DUMP_ASSET_PATH + "game_master");
master = this.parseProtobuf(data, "POGOProtos.Networking.Responses.DownloadItemTemplatesResponse");
} catch (e) {
this.print(e, 31);
}
return (master);
}
export function onFirstRun(resolve) {
pogo.login({
provider: CFG.DOWNLOAD_PROVIDER, // google or ptc
username: CFG.DOWNLOAD_USERNAME,
password: CFG.DOWNLOAD_PASSWORD
}).then((asset) => {
}).then((res) => {
let asset = res.asset;
this.print(`Dumping asset digest..`, 35);
// create data dir, if login successed
fse.ensureDirSync(CFG.DUMP_ASSET_PATH);
fs.writeFileSync(CFG.DUMP_ASSET_PATH + "asset_digest", asset.toBuffer());
fs.writeFileSync(CFG.DUMP_ASSET_PATH + "asset_digest", res.asset.toBuffer());
fs.writeFileSync(CFG.DUMP_ASSET_PATH + "game_master", res.master.toBuffer());
this.dumpPkmnModels(() => {
resolve();
});
}).catch((e) => {
this.print(e, 31);
});
}

View File

@@ -57,8 +57,33 @@ export function decodeLong(long) {
}
/**
* @return {Number}
*/
export function randomRequestId() {
return (
1e18 - Math.floor(Math.random() * 1e18)
);
}
/**
* @param {String} key
* @return {String}
*/
export function _toCC(key) {
key = key.toLowerCase();
let res = key[0].toUpperCase() + key.substring(1, key.length).replace(/_\s*([a-z])/g, function(d, e) {
return e.toUpperCase();
});
return (res);
}
/**
* @param {Number} index
* @return {String}
*/
export function idToPkmnBundleName(index) {
return (
"pm" + (index >= 10 ? index >= 100 ? "0" : "00" : "000") + index
);
}