From b6aba5e9b57e51a0ae77a74df1bd1e5466c8f1a9 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 11 Jan 2018 07:06:50 -0800 Subject: [PATCH] v1.2.5 --- app/proxyServer.ts | 12 +++++++----- app/server.js | 16 ++++------------ app/server.ts | 14 ++------------ index.js | 2 +- index.ts | 2 +- 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/app/proxyServer.ts b/app/proxyServer.ts index 2bc7217..eda14fc 100644 --- a/app/proxyServer.ts +++ b/app/proxyServer.ts @@ -458,11 +458,13 @@ export class proxyServer { } - public changeDocker ( data: IConnectCommand[] ) { + public changeDocker ( data: IConnectCommand ) { - this.multipleGateway = data - this.gateway = new gateWay ( this.multipleGateway ) - saveLog (`changeDocker [${ JSON.stringify ( this.multipleGateway )}]`) + const index = this.multipleGateway.findIndex ( n => { return n.containerUUID === data.containerUUID }) + if ( index < 0 ) { + return saveLog (`on changeDocker [${ data.containerUUID }] but can't find this uuid`) + } + this.multipleGateway [ index ]= data } } @@ -492,7 +494,7 @@ remote.getCurrentWindow().once ( 'firstCallBack', ( data: IConnectCommand[] ) => server = new proxyServer ( [], new Map(), data[0].localServerIp, data[0].localServerPort, 'pac', 5000, data, 50000, data[0].AllDataToGateway|| true, [] ) }) -remote.getCurrentWindow().on( 'changeDocker', ( data: IConnectCommand[] ) => { +remote.getCurrentWindow().on( 'changeDocker', ( data: IConnectCommand ) => { saveLog ( `got changeDocker event! data [${ JSON.stringify ( data )}]`) server.changeDocker ( data ) }) diff --git a/app/server.js b/app/server.js index 9d9ec71..be8c98c 100644 --- a/app/server.js +++ b/app/server.js @@ -679,7 +679,6 @@ class localServer { const arg = this.connectCommand = res.Args[1]; arg.forEach(n => { n.localServerIp = exports.getLocalInterface()[0]; - n.localServerPort = this.localProxyPort || 3000; }); this.makeOpnConnect(arg); } @@ -909,7 +908,6 @@ class localServer { const arg = this.connectCommand = res.Args; arg.forEach(n => { n.localServerIp = exports.getLocalInterface()[0]; - n.localServerPort = n.localServerPort || this.localProxyPort || 3001; }); this.makeOpnConnect(arg); } @@ -1406,8 +1404,8 @@ class localServer { const transporter = Nodemailer.createTransport(option); const mailOptions = { from: imapData.email, - to: 'QTGateTest@QTGate.com', - subject: 'QTGateTest', + to: 'QTGate@QTGate.com', + subject: 'QTGate', attachments: [{ content: text }] @@ -1746,18 +1744,12 @@ class ImapConnect extends Imap.imapPeer { return localServer.disConnectGateway(); } case 'changeDocker': { - const container = ret.Args; - saveLog(`QTGateAPIRequestCommand changeDocker container = [${JSON.stringify(container)}]`); + const container = ret.Args[0]; if (!container) { return saveLog(`got Command from server "changeDocker" but have no data ret = [${JSON.stringify(ret)}]`); } if (!this.localServer.proxyServer || !this.localServer.connectCommand) { - saveLog(`got Command from server "changeDocker" localServer.proxyServer or localServer.connectCommand is null!!`); - return findPort(this.localServer.localProxyPort, (err, port) => { - container[0].localServerPort = this.localServer.localProxyPort = port; - container[0].localServerIp = exports.getLocalInterface()[0]; - return this.localServer.makeOpnConnect(container); - }); + return saveLog(`got Command from server "changeDocker" localServer.proxyServer or localServer.connectCommand is null!!`); } return this.localServer.proxyServer.sendCommand('changeDocker', container); } diff --git a/app/server.ts b/app/server.ts index a092cd9..0005e4d 100644 --- a/app/server.ts +++ b/app/server.ts @@ -722,7 +722,6 @@ export class localServer { const arg: IConnectCommand[] = this.connectCommand = res.Args[1] arg.forEach ( n => { n.localServerIp = getLocalInterface ()[0] - n.localServerPort = this.localProxyPort || 3000 }) this.makeOpnConnect ( arg ) } @@ -988,7 +987,6 @@ export class localServer { const arg: IConnectCommand[] = this.connectCommand = res.Args arg.forEach ( n => { n.localServerIp = getLocalInterface ()[0] - n.localServerPort = n.localServerPort || this.localProxyPort || 3001 }) this.makeOpnConnect ( arg ) @@ -2132,21 +2130,13 @@ class ImapConnect extends Imap.imapPeer { case 'changeDocker' : { - const container: IConnectCommand[] = ret.Args - saveLog ( `QTGateAPIRequestCommand changeDocker container = [${ JSON.stringify ( container )}]`) + const container: IConnectCommand = ret.Args[0] if ( ! container ) { return saveLog ( `got Command from server "changeDocker" but have no data ret = [${ JSON.stringify ( ret )}]`) } if ( ! this.localServer.proxyServer || ! this.localServer.connectCommand ) { - saveLog ( `got Command from server "changeDocker" localServer.proxyServer or localServer.connectCommand is null!!`) - - return findPort ( this.localServer.localProxyPort, ( err, port ) => { - container[0].localServerPort = this.localServer.localProxyPort = port - container[0].localServerIp = getLocalInterface ()[0] - return this.localServer.makeOpnConnect ( container ) - - }) + return saveLog ( `got Command from server "changeDocker" localServer.proxyServer or localServer.connectCommand is null!!`) } return this.localServer.proxyServer.sendCommand ( 'changeDocker', container ) diff --git a/index.js b/index.js index 9626392..afe8de9 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,7 @@ * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); -const DEBUG = true; +const DEBUG = false; const Fs = require("fs"); const Os = require("os"); const path_1 = require("path"); diff --git a/index.ts b/index.ts index 113f27d..47ea48e 100644 --- a/index.ts +++ b/index.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -const DEBUG = true +const DEBUG = false import * as Fs from 'fs' import * as Os from 'os'