Skip to content

Commit

Permalink
v1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
peter authored and peter committed Jan 11, 2018
1 parent c399ef2 commit b6aba5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
12 changes: 7 additions & 5 deletions app/proxyServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
Expand Down Expand Up @@ -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 )
})
Expand Down
16 changes: 4 additions & 12 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}]
Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 2 additions & 12 deletions app/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
}
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

const DEBUG = true
const DEBUG = false

import * as Fs from 'fs'
import * as Os from 'os'
Expand Down

0 comments on commit b6aba5e

Please sign in to comment.