로그인시 로컬 IP, MAC 정보 송신하도록 수정 :: 세션 로그아웃시 해당 정보 내려주기로 함. [재업로드]

This commit is contained in:
leejinho 2019-12-24 17:31:03 +09:00
parent 5ce3d5fe02
commit 82f53a0a28
7 changed files with 79 additions and 28 deletions

View File

@ -10,6 +10,7 @@ import {
import path from 'path'; import path from 'path';
import fse from 'fs-extra'; import fse from 'fs-extra';
import semver from 'semver'; import semver from 'semver';
import os from 'os';
import AutoLaunch from 'auto-launch'; import AutoLaunch from 'auto-launch';
@ -358,6 +359,27 @@ ipcMain.on(UpdaterChannel.Check, (event: IpcMainEvent, ...args: any[]) => {
} }
}); });
ipcMain.on(
MessengerChannel.GetNetworkInfo,
(event: IpcMainEvent, ...args: any[]) => {
const interfaces = os.networkInterfaces();
const addresses: { ip: string; mac: string }[] = [];
// tslint:disable-next-line: forin
for (const k in interfaces) {
// tslint:disable-next-line: forin
for (const k2 in interfaces[k]) {
const address = interfaces[k][k2];
if (address.family === 'IPv4' && !address.internal) {
addresses.push({ ip: address.address, mac: address.mac });
}
}
}
event.returnValue = addresses;
}
);
ipcMain.on( ipcMain.on(
MessengerChannel.ChangeAutoLaunch, MessengerChannel.ChangeAutoLaunch,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {

View File

@ -1,4 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable, Inject } from '@angular/core';
import { import {
Resolve, Resolve,
ActivatedRouteSnapshot, ActivatedRouteSnapshot,
@ -60,12 +60,13 @@ import {
UrlInfoResponse, UrlInfoResponse,
DaesangUrlInfoResponse DaesangUrlInfoResponse
} from '@ucap-webmessenger/api-external'; } from '@ucap-webmessenger/api-external';
import { DeviceType } from '@ucap-webmessenger/core';
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
@Injectable() @Injectable()
export class AppMessengerResolver implements Resolve<void> { export class AppMessengerResolver implements Resolve<void> {
constructor( constructor(
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private store: Store<any>, private store: Store<any>,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private publicApiService: PublicApiService, private publicApiService: PublicApiService,
@ -84,7 +85,7 @@ export class AppMessengerResolver implements Resolve<void> {
activatedRouteSnapshot: ActivatedRouteSnapshot, activatedRouteSnapshot: ActivatedRouteSnapshot,
routerStateSnapshot: RouterStateSnapshot routerStateSnapshot: RouterStateSnapshot
): void | Observable<void> | Promise<void> { ): void | Observable<void> | Promise<void> {
return new Promise<void>((resolve, reject) => { return new Promise<void>(async (resolve, reject) => {
let loginRes: LoginResponse; let loginRes: LoginResponse;
const loginInfo = this.sessionStorageService.get<LoginInfo>( const loginInfo = this.sessionStorageService.get<LoginInfo>(
@ -94,6 +95,24 @@ export class AppMessengerResolver implements Resolve<void> {
KEY_ENVIRONMENTS_INFO KEY_ENVIRONMENTS_INFO
); );
let localIp = '';
let localMac = '';
// get network info
await this.nativeService
.getNetworkInfo()
.then(result => {
if (!!result && result.length > 0) {
if (!!result[0].ip) {
localIp = result[0].ip;
}
if (!!result[0].mac) {
localMac = result[0].mac;
}
}
})
.catch(reason => {});
this.publicApiService this.publicApiService
.versionInfo2({ .versionInfo2({
deviceType: environmentsInfo.deviceType, deviceType: environmentsInfo.deviceType,
@ -146,12 +165,12 @@ export class AppMessengerResolver implements Resolve<void> {
passwordEncodingType: 1, passwordEncodingType: 1,
clientVersion: '', clientVersion: '',
reconnect: false, reconnect: false,
ip: 'localhost', ip: localIp,
hostName: '', hostName: localMac,
ssoMode: SSOMode.AUTH, ssoMode: SSOMode.AUTH,
userSpecificInformation: 'PRO_000482', userSpecificInformation: 'PRO_000482',
productId: environment.productConfig.productId, andId: '',
productName: environment.productConfig.productName andPushRefreshYn: ''
}) })
.pipe( .pipe(
catchError(err => { catchError(err => {

View File

@ -72,6 +72,12 @@ export class BrowserNativeService extends NativeService {
}); });
} }
getNetworkInfo(): Promise<any> {
return new Promise<any>((resolve, reject) => {
resolve(null);
});
}
changeAutoLaunch(autoLaunch: boolean): Promise<boolean> { changeAutoLaunch(autoLaunch: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => { return new Promise<boolean>((resolve, reject) => {
resolve(true); resolve(true);

View File

@ -78,6 +78,16 @@ export class ElectronNativeService implements NativeService {
return this.logout$; return this.logout$;
} }
getNetworkInfo(): Promise<any> {
return new Promise<string>((resolve, reject) => {
try {
resolve(this.ipcRenderer.sendSync(MessengerChannel.GetNetworkInfo));
} catch (error) {
reject(error);
}
});
}
changeStatus(): Observable<StatusCode> { changeStatus(): Observable<StatusCode> {
if (!this.changeStatusSubject) { if (!this.changeStatusSubject) {
this.changeStatusSubject = new Subject<StatusCode>(); this.changeStatusSubject = new Subject<StatusCode>();

View File

@ -3,7 +3,8 @@ export enum MessengerChannel {
ChangeStatus = 'UCAP::messenger::changeStatus', ChangeStatus = 'UCAP::messenger::changeStatus',
ShowSetting = 'UCAP::messenger::showSetting', ShowSetting = 'UCAP::messenger::showSetting',
ChangeAutoLaunch = 'UCAP::messenger::changeAutoLaunch', ChangeAutoLaunch = 'UCAP::messenger::changeAutoLaunch',
ChangeStartupHideWindow = 'UCAP::messenger::changeStartupHideWindow' ChangeStartupHideWindow = 'UCAP::messenger::changeStartupHideWindow',
GetNetworkInfo = 'UCAP::messenger::getNetworkInfo'
} }
export enum ChatChannel { export enum ChatChannel {

View File

@ -24,6 +24,8 @@ export abstract class NativeService {
abstract changeStatus(): Observable<StatusCode>; abstract changeStatus(): Observable<StatusCode>;
abstract showSetting(): Observable<void>; abstract showSetting(): Observable<void>;
abstract getNetworkInfo(): Promise<any>;
abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>; abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>;
abstract changeStartupHideWindow( abstract changeStartupHideWindow(
startupHideWindow: boolean startupHideWindow: boolean

View File

@ -46,14 +46,10 @@ export interface LoginRequest extends ProtocolRequest {
ssoMode: SSOMode; ssoMode: SSOMode;
// 14. 사용자고유정보(s) // 14. 사용자고유정보(s)
userSpecificInformation: string; userSpecificInformation: string;
// 15. 제품 ID(s) // 15. 안드로이드 ID(s)
productId: string; andId: string;
// 16. 제품명(s) // 16. push_ID 갱신여부(s)
productName: string; andPushRefreshYn: string;
// 17. EncData(s)
encriptionData?: string;
// 18. AccessToken(s)
accessToken?: string;
} }
export interface LoginResponse extends ProtocolResponse { export interface LoginResponse extends ProtocolResponse {
@ -135,25 +131,20 @@ export const encodeLogin: ProtocolEncoder<LoginRequest> = (
{ type: PacketBodyValue.String, value: req.deviceId }, { type: PacketBodyValue.String, value: req.deviceId },
{ type: PacketBodyValue.String, value: req.token }, { type: PacketBodyValue.String, value: req.token },
{ type: PacketBodyValue.String, value: req.localeCode }, { type: PacketBodyValue.String, value: req.localeCode },
{ type: PacketBodyValue.String, value: req.pushId }, { type: PacketBodyValue.String, value: req.pushId }, // 6
{ type: PacketBodyValue.String, value: req.companyCode }, { type: PacketBodyValue.String, value: req.companyCode },
{ type: PacketBodyValue.Integer, value: req.passwordEncodingType }, { type: PacketBodyValue.Integer, value: req.passwordEncodingType },
{ type: PacketBodyValue.String, value: req.clientVersion }, { type: PacketBodyValue.String, value: req.clientVersion },
{ type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' }, { type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' },
{ type: PacketBodyValue.String, value: req.ip }, { type: PacketBodyValue.String, value: req.ip },
{ type: PacketBodyValue.String, value: req.hostName }, { type: PacketBodyValue.String, value: req.hostName },
{ type: PacketBodyValue.Integer, value: req.encriptionData ? 2 : 1 }, { type: PacketBodyValue.String, value: '' }, // 13
{ type: PacketBodyValue.String, value: req.userSpecificInformation },
{ type: PacketBodyValue.String, value: req.productId },
{ type: PacketBodyValue.String, value: req.productName }
);
if (req.encriptionData) { { type: PacketBodyValue.String, value: req.userSpecificInformation },
bodyList.push( { type: PacketBodyValue.String, value: req.andId },
{ type: PacketBodyValue.String, value: req.encriptionData }, { type: PacketBodyValue.String, value: req.andPushRefreshYn }
{ type: PacketBodyValue.String, value: req.accessToken }
); );
}
return bodyList; return bodyList;
}; };