mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-07-09 13:46:11 -05:00
- Added asset session downloader - Added on off option logging request types - Updated proto files - Updated readme.md - Smoother setup process - Added various console commands - Added claim codename packet - Added encounter packet - Added *fixed* download url packet - Various changes, cant remember at all
120 lines
2.0 KiB
JavaScript
120 lines
2.0 KiB
JavaScript
import Long from "long";
|
|
import proto from "./proto";
|
|
import { DownloadUrls } from "./res";
|
|
|
|
import * as CFG from "../cfg";
|
|
|
|
/**
|
|
* @param {Object} cls
|
|
* @param {Object} prot
|
|
* @export
|
|
*/
|
|
export function inherit(cls, prot) {
|
|
|
|
let key = null;
|
|
|
|
for (key in prot) {
|
|
if (prot[key] instanceof Function) {
|
|
cls.prototype[key] = prot[key];
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
* @param {Buffer} body
|
|
*/
|
|
export function decodeRequestEnvelope(body) {
|
|
return (
|
|
proto.Networking.Envelopes.RequestEnvelope.decode(body)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* http://stackoverflow.com/a/7616484/3367904
|
|
* @param {String} str
|
|
* @return {String}
|
|
*/
|
|
export function getHashCodeFrom(str) {
|
|
var hash = 0, i, chr, len;
|
|
if (str.length === 0) return hash;
|
|
for (i = 0, len = str.length; i < len; i++) {
|
|
chr = str.charCodeAt(i);
|
|
hash = ((hash << 5) - hash) + chr;
|
|
hash |= 0; // Convert to 32bit integer
|
|
}
|
|
return hash;
|
|
};
|
|
|
|
/**
|
|
* @param {Long} long
|
|
* @return {Number}
|
|
*/
|
|
export function decodeLong(long) {
|
|
|
|
let value = Long.fromBits(long.high, long.low, !!long.unsigned);
|
|
|
|
return (parseInt(value.toString()));
|
|
|
|
}
|
|
|
|
/**
|
|
* @param {String} pm
|
|
* @return {Object}
|
|
*/
|
|
export function getDownloadUrl(pm) {
|
|
|
|
let ii = 0;
|
|
let length = DownloadUrls.length;
|
|
|
|
let node = null;
|
|
|
|
for (; ii < length; ++ii) {
|
|
node = DownloadUrls[ii];
|
|
if (node.bundle_name === pm) {
|
|
return (node);
|
|
}
|
|
};
|
|
|
|
return (null);
|
|
|
|
}
|
|
|
|
/**
|
|
* @param {String} pm
|
|
* @return {Object}
|
|
*/
|
|
export function getDownloadUrlByAssetId(id) {
|
|
|
|
let ii = 0;
|
|
let length = DownloadUrls.length;
|
|
|
|
let node = null;
|
|
let index = 0;
|
|
|
|
for (; ii < length; ++ii) {
|
|
node = DownloadUrls[ii];
|
|
if (node.asset_id.substring(index) === id) {
|
|
return (node);
|
|
}
|
|
};
|
|
|
|
return (null);
|
|
|
|
}
|
|
|
|
export function getGenerationIdByAssetId(asset_id) {
|
|
|
|
let index = asset_id.lastIndexOf("/") + 1;
|
|
|
|
return (
|
|
parseInt(asset_id.substring(index))
|
|
);
|
|
|
|
}
|
|
|
|
export function randomRequestId() {
|
|
return (
|
|
1e18 - Math.floor(Math.random() * 1e18)
|
|
);
|
|
} |