Cleanup code

This commit is contained in:
root 2020-06-26 14:51:12 +07:00
parent a2be042be9
commit 40b8b9195a

View File

@ -68,13 +68,11 @@ const getServers = (serv = null, nocheck = false) => {
const reqVersion = https.request(ms_opts, (resVersion) => { const reqVersion = https.request(ms_opts, (resVersion) => {
resVersion.on('data', (dataVersion) => { resVersion.on('data', (dataVersion) => {
let resVers = JSON.parse(dataVersion); let resVers = JSON.parse(dataVersion);
//console.log('Version:', JSON.stringify(resVers, null, 2));
ms_opts.path = `/v${resVers.version}/config.json`; ms_opts.path = `/v${resVers.version}/config.json`;
// Запрос конфигурации // Запрос конфигурации
const reqConfig = https.request(ms_opts, (resConfig) => { const reqConfig = https.request(ms_opts, (resConfig) => {
resConfig.on('data', (dataConfig) => { resConfig.on('data', (dataConfig) => {
let resCfg = JSON.parse(dataConfig); let resCfg = JSON.parse(dataConfig);
//console.log('Config:', JSON.stringify(resCfg, null, 2));
const mainland = url.parse(resCfg.ip[0].region_urls[0]); const mainland = url.parse(resCfg.ip[0].region_urls[0]);
ms_opts.hostname = mainland.hostname; ms_opts.hostname = mainland.hostname;
ms_opts.port = mainland.port; ms_opts.port = mainland.port;
@ -88,7 +86,6 @@ const getServers = (serv = null, nocheck = false) => {
const reqServers = https.request(ms_opts, (resServers) => { const reqServers = https.request(ms_opts, (resServers) => {
resServers.on('data', (dataServers) => { resServers.on('data', (dataServers) => {
let resServs = JSON.parse(dataServers); let resServs = JSON.parse(dataServers);
//console.log('Servers:', JSON.stringify(resServs, null, 2));
if (serv && !nocheck) { if (serv && !nocheck) {
if (resServs.servers.indexOf(serv) >= 0) { if (resServs.servers.indexOf(serv) >= 0) {
resolve([serv]); resolve([serv]);
@ -152,19 +149,11 @@ const sendRequest = (server, package_name, service_name, method_name, params, id
client = new WebSocketClient(), client = new WebSocketClient(),
service = proto.lookup(`${package_name}.${service_name}`), service = proto.lookup(`${package_name}.${service_name}`),
method = service.methods[method_name].resolve(), method = service.methods[method_name].resolve(),
req = method.resolvedRequestType,
res = method.resolvedResponseType, res = method.resolvedResponseType,
wrapper = proto.lookupType(`${package_name}.Wrapper`); wrapper = proto.lookupType(`${package_name}.Wrapper`);
let req_str = wrapper.create({
//name: `${req.name}`,
name: `${package_name}.${req.name}`,
//data: params
data: req.encode(params).finish()
});
let meth_str = wrapper.create({ let meth_str = wrapper.create({
name: `${package_name}.${service_name}.${method_name}`, name: `${package_name}.${service_name}.${method_name}`,
data: wrapper.encode(params).finish() data: wrapper.encode(params).finish()
//data: wrapper.encode(req_str).finish()
}); });
let msg = wrapper.encode(meth_str).finish(), let msg = wrapper.encode(meth_str).finish(),
pkt_type = [Number(2)], pkt_type = [Number(2)],
@ -308,11 +297,9 @@ if (!args || args.help) {
console.log(`Use server: ${server}`); console.log(`Use server: ${server}`);
let idx = Math.floor(60007 * Math.random()), let idx = Math.floor(60007 * Math.random()),
params = { params = {
//account_id: 117411310 code: '111111',
code: '526091',
operation: 0 operation: 0
}; };
//sendRequest(server, 'lq', 'Lobby', 'fetchConnectionInfo', params, idx).then(
sendRequest(server, 'lq', 'Lobby', 'verfifyCodeForSecure', params, idx).then( sendRequest(server, 'lq', 'Lobby', 'verfifyCodeForSecure', params, idx).then(
resSend => { resSend => {
console.log(`Result: ${JSON.stringify(resSend, null, 2)}`); console.log(`Result: ${JSON.stringify(resSend, null, 2)}`);