添加ip归属地
This commit is contained in:
@@ -21,6 +21,7 @@ import { getExpByLv } from '../../../pubUtils/data';
|
||||
import { reportCreateRoleEventToTa, reportTAEvent, reportTAUserSet } from '../../../services/sdkService';
|
||||
import { saveLoginAndOutLog } from '../../../pubUtils/logUtil';
|
||||
import { sendMessageToAllWithSuc } from '../../../services/pushService';
|
||||
import { setIpLocation } from '../../../services/roleService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -63,6 +64,8 @@ export class EntryHandler {
|
||||
return resResult(STATUS.ROLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
setIpLocation(role.roleId, this.getIp(session));
|
||||
|
||||
let serverName = this.app.getServerId();
|
||||
await roleLogin(role.roleId, user.userCode, serverName, role.createTime, role.serverId, role.lv, role.topLineupCe); // 保存在线用户
|
||||
await this.addSession(user, role, session);
|
||||
|
||||
@@ -13,6 +13,9 @@ import { Figure } from '../domain/dbGeneral';
|
||||
import { pick } from 'underscore';
|
||||
import { Reward } from '../domain/battleField/pvp';
|
||||
import { CheckMeterial } from './role/checkMaterial';
|
||||
import IP2Region from "ip2region";
|
||||
const query = new IP2Region({ disableIpv6: true });
|
||||
|
||||
|
||||
export async function getTeraphStrengthenResult(role: RoleType, count: number, dicTeraph: DicTeraph, teraph: Teraph) {
|
||||
let criAttr: number[] = [], times = 0;
|
||||
@@ -288,4 +291,14 @@ export async function getSchoolPoint(roleId: string) {
|
||||
}
|
||||
return pre;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
export async function setIpLocation(roleId: string, ip: string) {
|
||||
try {
|
||||
const res = query.search(ip);
|
||||
console.log('##### setIpLocation', res)
|
||||
await RoleModel.updateRoleInfo(roleId, { ip, ipLocation: res.province||res.country })
|
||||
} catch(e) {
|
||||
console.error('setIpLocation', e)
|
||||
}
|
||||
}
|
||||
5
game-server/package-lock.json
generated
5
game-server/package-lock.json
generated
@@ -1620,6 +1620,11 @@
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
|
||||
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
|
||||
},
|
||||
"ip2region": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ip2region/-/ip2region-2.3.0.tgz",
|
||||
"integrity": "sha512-zV5Xsadzrx9Ej6heoyhbXMsfGWWQ3C6bAIYStrHhw9kzLpGpVNlnAyRBxxPgxA1GNqr1Ti7oUxcWsMWNN3jZBg=="
|
||||
},
|
||||
"is-binary-path": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"crc": "^3.5.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"csprng": "^0.1.2",
|
||||
"ip2region": "^2.3.0",
|
||||
"koa-is-json": "^1.0.0",
|
||||
"local": "^0.3.3",
|
||||
"moment": "^2.29.1",
|
||||
|
||||
Reference in New Issue
Block a user