Skip to content

Commit c399ef2

Browse files
peterpeter
authored andcommitted
v1.2.5
1 parent dedaa26 commit c399ef2

12 files changed

Lines changed: 126 additions & 138 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
- **QTStorage** – Encrypted, private data storage and secret sharing services.
2323

24+
Need help [Gitter online chat](https://gitter.im/QTGate/Lobby)
2425
***
2526
QTGate端末インストールです.
2627

@@ -48,6 +49,7 @@ QTGateとは匿名ネットワークです。QTGateは三つのツールを構
4849

4950
安全なプライベットファイルクラウドストレージ及びシェアプラットフォームです。
5051

52+
ヘルプ[Gitterチャットへようこそ](https://gitter.im/QTGate/%E6%97%A5%E6%9C%AC%E8%AA%9E)
5153
***
5254
**Q梯**匿名網絡環境客戶端安裝程序。
5355

@@ -71,6 +73,8 @@ QTGateとは匿名ネットワークです。QTGateは三つのツールを構
7173
- 劍客三 **Q梯石洞**(QTStorage)本功能免費
7274
* 使用Email帳戶內剩餘的容量,無限量(可申請多個email帳戶)私密文件雲存儲和分享功能。**Q梯石洞**通過此客戶端提供本地網站服務器,讓手機和其他設備不用安裝專用軟件,對文件進行操作。
7375

76+
需要幫助,請聯繫我們在[Gitter會議室](https://gitter.im/QTGate/%E4%B8%AD%E6%96%87)
77+
7478
***
7579
![http protocol](/resources/canada150.png?raw=true)
7680
***

app/imap.js

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,44 +1099,45 @@ class imapPeer extends Event.EventEmitter {
10991099
mail(email) {
11001100
const attr = exports.getMailAttached(email).toString();
11011101
this.deCrypto(attr, (err, data) => {
1102-
if (err)
1102+
if (err) {
11031103
return saveLog(`deCrypto GOT ERROR! [${err.message}]`);
1104+
}
1105+
let uu = null;
11041106
try {
1105-
const uu = JSON.parse(data);
1106-
if (uu.ping && uu.ping.length) {
1107-
saveLog('GOT PING REPLY PONG!');
1108-
if (!this.peerReady) {
1109-
if (/outlook\.com/i.test(this.imapData.imapServer)) {
1110-
saveLog(`doing outlook server support!`);
1111-
return timers_1.setTimeout(() => {
1112-
saveLog(`outlook replyPing ()`);
1113-
this.pingUuid = null;
1114-
this.replyPing(uu);
1115-
return this.Ping();
1116-
}, 5000);
1117-
}
1118-
this.replyPing(uu);
1119-
saveLog(`THIS peerConnect have not ready send ping!`);
1120-
this.pingUuid = null;
1121-
return this.Ping();
1122-
}
1123-
return this.replyPing(uu);
1124-
}
1125-
if (uu.pong && uu.pong.length) {
1126-
if (!this.pingUuid || this.pingUuid !== uu.pong) {
1127-
return saveLog(`Invalid ping uuid [${JSON.stringify(uu)}]`);
1107+
uu = JSON.parse(data);
1108+
}
1109+
catch (ex) {
1110+
return saveLog(`imapPeer mail deCrypto JSON.parse got ERROR [${ex.message}]`);
1111+
}
1112+
if (uu.ping && uu.ping.length) {
1113+
saveLog('GOT PING REPLY PONG!');
1114+
if (!this.peerReady) {
1115+
if (/outlook\.com/i.test(this.imapData.imapServer)) {
1116+
saveLog(`doing outlook server support!`);
1117+
return timers_1.setTimeout(() => {
1118+
saveLog(`outlook replyPing ()`);
1119+
this.pingUuid = null;
1120+
this.replyPing(uu);
1121+
return this.Ping();
1122+
}, 5000);
11281123
}
1129-
saveLog(`imapPeer connected Clear waitingReplyTimeOut!`);
1124+
this.replyPing(uu);
1125+
saveLog(`THIS peerConnect have not ready send ping!`);
11301126
this.pingUuid = null;
1131-
timers_1.clearTimeout(this.waitingReplyTimeOut);
1132-
return this.emit('ready');
1127+
return this.Ping();
11331128
}
1134-
return this.newMail(uu);
1129+
return this.replyPing(uu);
11351130
}
1136-
catch (ex) {
1137-
saveLog(`imapPeer mail deCrypto JSON.parse got ERROR [${ex.message}]`);
1138-
return;
1131+
if (uu.pong && uu.pong.length) {
1132+
if (!this.pingUuid || this.pingUuid !== uu.pong) {
1133+
return saveLog(`Invalid ping uuid [${JSON.stringify(uu)}]`);
1134+
}
1135+
saveLog(`imapPeer connected Clear waitingReplyTimeOut!`);
1136+
this.pingUuid = null;
1137+
timers_1.clearTimeout(this.waitingReplyTimeOut);
1138+
return this.emit('ready');
11391139
}
1140+
return this.newMail(uu);
11401141
});
11411142
}
11421143
trySendToRemote(email, CallBack) {

app/imap.ts

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,49 +1259,50 @@ export class imapPeer extends Event.EventEmitter {
12591259
const attr = getMailAttached ( email ).toString ()
12601260

12611261
this.deCrypto ( attr, ( err, data ) => {
1262-
if ( err )
1262+
if ( err ) {
12631263
return saveLog ( `deCrypto GOT ERROR! [${ err.message }]` )
1264+
}
1265+
let uu = null
12641266
try {
1265-
const uu = JSON.parse ( data )
1266-
1267-
if ( uu.ping && uu.ping.length ) {
1268-
saveLog ( 'GOT PING REPLY PONG!' )
1269-
1270-
if ( ! this.peerReady ) {
1271-
1272-
if ( /outlook\.com/i.test ( this.imapData.imapServer)) {
1273-
saveLog ( `doing outlook server support!`)
1274-
return setTimeout (() => {
1275-
saveLog (`outlook replyPing ()`)
1276-
this.pingUuid = null
1277-
this.replyPing ( uu )
1278-
return this.Ping ( )
1279-
}, 5000 )
1280-
}
1281-
this.replyPing ( uu )
1282-
saveLog ( `THIS peerConnect have not ready send ping!`)
1283-
1284-
this.pingUuid = null
1285-
return this.Ping ( )
1286-
}
1287-
return this.replyPing ( uu )
1288-
}
1267+
uu = JSON.parse ( data )
1268+
} catch ( ex ) {
1269+
return saveLog ( `imapPeer mail deCrypto JSON.parse got ERROR [${ ex.message }]`)
1270+
}
1271+
if ( uu.ping && uu.ping.length ) {
1272+
saveLog ( 'GOT PING REPLY PONG!' )
12891273

1290-
if ( uu.pong && uu.pong.length ) {
1291-
if ( !this.pingUuid || this.pingUuid !== uu.pong ) {
1292-
return saveLog (`Invalid ping uuid [${ JSON.stringify ( uu )}]`)
1274+
if ( ! this.peerReady ) {
1275+
1276+
if ( /outlook\.com/i.test ( this.imapData.imapServer)) {
1277+
saveLog ( `doing outlook server support!`)
1278+
return setTimeout (() => {
1279+
saveLog (`outlook replyPing ()`)
1280+
this.pingUuid = null
1281+
this.replyPing ( uu )
1282+
return this.Ping ( )
1283+
}, 5000 )
12931284
}
1294-
saveLog ( `imapPeer connected Clear waitingReplyTimeOut!`)
1285+
this.replyPing ( uu )
1286+
saveLog ( `THIS peerConnect have not ready send ping!`)
1287+
12951288
this.pingUuid = null
1296-
clearTimeout ( this.waitingReplyTimeOut )
1297-
return this.emit ('ready')
1289+
return this.Ping ( )
12981290
}
1299-
return this.newMail (uu )
1300-
1301-
} catch ( ex ) {
1302-
saveLog ( `imapPeer mail deCrypto JSON.parse got ERROR [${ ex.message }]`)
1303-
return
1291+
return this.replyPing ( uu )
13041292
}
1293+
1294+
if ( uu.pong && uu.pong.length ) {
1295+
if ( !this.pingUuid || this.pingUuid !== uu.pong ) {
1296+
return saveLog (`Invalid ping uuid [${ JSON.stringify ( uu )}]`)
1297+
}
1298+
saveLog ( `imapPeer connected Clear waitingReplyTimeOut!`)
1299+
this.pingUuid = null
1300+
clearTimeout ( this.waitingReplyTimeOut )
1301+
return this.emit ('ready')
1302+
}
1303+
return this.newMail (uu )
1304+
1305+
13051306
})
13061307

13071308
}

app/proxyServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ const saveLog = ( log: string ) => {
487487

488488
let server: proxyServer = null
489489
remote.getCurrentWindow().once ( 'firstCallBack', ( data: IConnectCommand[] ) => {
490-
saveLog ( `************************** start proxyServer *****************************\r\n ${ JSON.stringify( data )}\r\n` )
490+
console.log ( `************************** start proxyServer *****************************\r\n ${ data }\r\n` )
491491

492-
server = new proxyServer ( [], new Map(), data[0].localServerIp, data[0].localServerPort, 'pac', 5000, data, 50000, data[0].AllDataToGateway, [] )
492+
server = new proxyServer ( [], new Map(), data[0].localServerIp, data[0].localServerPort, 'pac', 5000, data, 50000, data[0].AllDataToGateway|| true, [] )
493493
})
494494

495495
remote.getCurrentWindow().on( 'changeDocker', ( data: IConnectCommand[] ) => {

app/public/scripts/home.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,8 +3730,8 @@ var view_layout;
37303730
socketIo.on('disconnectClickCallBack', () => {
37313731
return this.desconnectCallBack();
37323732
});
3733-
socketIo.on('QTGateGatewayConnectRequest', data => {
3734-
return this.QTGateGatewayConnectRequestCallBack(this, data);
3733+
socketIo.on('QTGateGatewayConnectRequest', (err, data) => {
3734+
return this.QTGateGatewayConnectRequestCallBack(this, err, data);
37353735
});
37363736
socketIo.on('pingCheck', (region, ping) => {
37373737
return this.pingCheckReturn(region, ping);
@@ -4229,24 +4229,24 @@ var view_layout;
42294229
doingProcessBar();
42304230
data.showExtraContent(false);
42314231
data.showRegionConnectProcessBar(true);
4232-
socketIo.emit('QTGateGatewayConnectRequest', connect, (_data) => {
4233-
return this.QTGateGatewayConnectRequestCallBack(this, _data);
4232+
socketIo.emit('QTGateGatewayConnectRequest', connect, (err, _data) => {
4233+
return this.QTGateGatewayConnectRequestCallBack(this, err, _data);
42344234
});
42354235
return false;
42364236
});
42374237
}
4238-
QTGateGatewayConnectRequestCallBack(_self, _returnData) {
4238+
QTGateGatewayConnectRequestCallBack(_self, error, connectCommand) {
42394239
clearTimeout(this.doingProcessBarTime);
42404240
const selectedQTGateRegion = this.selectedQTGateRegion();
42414241
selectedQTGateRegion.showRegionConnectProcessBar(false);
4242-
if (_returnData.error > -1) {
4242+
if (error > -1) {
42434243
selectedQTGateRegion.showExtraContent(true);
42444244
//this.QTGateConnectRegionActive ( true )
42454245
//this.QTGateGatewayActiveProcess ( false )
4246-
selectedQTGateRegion.error(_returnData.error);
4246+
selectedQTGateRegion.error(error);
42474247
return this.menuClick(3, true);
42484248
}
4249-
const data1 = _returnData.Args[0];
4249+
const data1 = connectCommand[0];
42504250
this.QTTransferData(data1.transferData);
42514251
this.QTConnectData(data1);
42524252
$('.userDetail').progress();

app/public/scripts/home.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,8 +3833,8 @@ module view_layout {
38333833
return this.desconnectCallBack ()
38343834
})
38353835

3836-
socketIo.on ( 'QTGateGatewayConnectRequest', data => {
3837-
return this.QTGateGatewayConnectRequestCallBack ( this, data )
3836+
socketIo.on ( 'QTGateGatewayConnectRequest', ( err, data ) => {
3837+
return this.QTGateGatewayConnectRequestCallBack ( this, err, data )
38383838
})
38393839

38403840
socketIo.on ( 'pingCheck', ( region: string, ping: number ) => {
@@ -4469,27 +4469,27 @@ module view_layout {
44694469
data.showExtraContent ( false )
44704470
data.showRegionConnectProcessBar ( true )
44714471

4472-
socketIo.emit( 'QTGateGatewayConnectRequest', connect, ( _data: QTGateAPIRequestCommand ) => {
4473-
return this.QTGateGatewayConnectRequestCallBack ( this, _data )
4472+
socketIo.emit( 'QTGateGatewayConnectRequest', connect, ( err, _data: IConnectCommand[] ) => {
4473+
return this.QTGateGatewayConnectRequestCallBack ( this, err, _data )
44744474
})
44754475
return false
44764476
})
44774477

44784478

44794479
}
44804480

4481-
private QTGateGatewayConnectRequestCallBack ( _self: view, _returnData: QTGateAPIRequestCommand ) {
4481+
private QTGateGatewayConnectRequestCallBack ( _self: view, error, connectCommand: IConnectCommand[] ) {
44824482
clearTimeout ( this.doingProcessBarTime )
44834483
const selectedQTGateRegion = this.selectedQTGateRegion ()
44844484
selectedQTGateRegion.showRegionConnectProcessBar ( false )
4485-
if ( _returnData.error > -1 ) {
4485+
if ( error > -1 ) {
44864486
selectedQTGateRegion.showExtraContent ( true )
44874487
//this.QTGateConnectRegionActive ( true )
44884488
//this.QTGateGatewayActiveProcess ( false )
4489-
selectedQTGateRegion.error ( _returnData.error )
4489+
selectedQTGateRegion.error ( error )
44904490
return this.menuClick ( 3, true )
44914491
}
4492-
const data1:IConnectCommand = _returnData.Args[0]
4492+
const data1 = connectCommand[0]
44934493

44944494
this.QTTransferData ( data1.transferData )
44954495
this.QTConnectData ( data1 )

app/server.js

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,6 @@ class localServer {
622622
return CallBack(false);
623623
});
624624
}
625-
findPort(port, CallBack) {
626-
return this.findPort(port, good => {
627-
if (!good) {
628-
return findPort(++port, CallBack);
629-
}
630-
return CallBack(null, port);
631-
});
632-
}
633625
// After password
634626
listenAfterPassword(socket) {
635627
socket.on('startCheckImap', (id, imapData, CallBack) => {
@@ -683,16 +675,15 @@ class localServer {
683675
// Have gateway connect!
684676
this.saveConfig();
685677
if (res.Args[1]) {
686-
const uu = res.Args[1];
687678
if (!this.proxyServer || !this.connectCommand) {
688-
uu[0].localServerIp = exports.getLocalInterface()[0];
689-
return this.findPort(3000, (err, _port) => {
690-
uu[0].localServerIp = exports.getLocalInterface()[0];
691-
this.localProxyPort = uu[0].localServerPort = _port;
692-
return this.makeOpnConnect(uu);
679+
const arg = this.connectCommand = res.Args[1];
680+
arg.forEach(n => {
681+
n.localServerIp = exports.getLocalInterface()[0];
682+
n.localServerPort = this.localProxyPort || 3000;
693683
});
684+
this.makeOpnConnect(arg);
694685
}
695-
return socket.emit('QTGateGatewayConnectRequest', this.connectCommand);
686+
return socket.emit('QTGateGatewayConnectRequest', -1, res.Args[1]);
696687
}
697688
this.regionV1 = res.Args[2];
698689
});
@@ -915,14 +906,14 @@ class localServer {
915906
return saveLog(`request error`);
916907
}
917908
if (res.error < 0) {
918-
const arg = res.Args;
909+
const arg = this.connectCommand = res.Args;
919910
arg.forEach(n => {
920911
n.localServerIp = exports.getLocalInterface()[0];
921-
n.localServerPort = this.localProxyPort;
912+
n.localServerPort = n.localServerPort || this.localProxyPort || 3001;
922913
});
923914
this.makeOpnConnect(arg);
924915
}
925-
CallBack(res);
916+
CallBack(res.error, res.Args);
926917
saveLog(`res.error [${res.error}]`);
927918
});
928919
};
@@ -945,6 +936,7 @@ class localServer {
945936
this.socketServer.emit('qtGateConnect', this.qtGateConnectEmitData);
946937
}
947938
makeOpnConnect(arg) {
939+
saveLog(`makeOpnConnect arg = ${JSON.stringify(arg)}`);
948940
this.connectCommand = arg;
949941
const runCom = arg[0].connectType === 1 ? '@Opn' : 'iOpn';
950942
return this.proxyServer = new RendererProcess(runCom, arg, DEBUG, () => {
@@ -1151,7 +1143,7 @@ class localServer {
11511143
callBack(true, this.imapDataPool);
11521144
this.listenAfterPassword(socket);
11531145
if (this.connectCommand && this.httpServer) {
1154-
return socket.emit('QTGateGatewayConnectRequest', this.connectCommand);
1146+
return socket.emit('QTGateGatewayConnectRequest', -1, this.connectCommand);
11551147
}
11561148
// imapDataPool have QTGateImap doing emitQTGateToClient
11571149
if (this.imapDataPool.length > 0 && findQTGateImap(this.imapDataPool) > -1)
@@ -1414,7 +1406,7 @@ class localServer {
14141406
const transporter = Nodemailer.createTransport(option);
14151407
const mailOptions = {
14161408
from: imapData.email,
1417-
to: 'QTGate@QTGate.com',
1409+
to: 'QTGateTest@QTGate.com',
14181410
subject: 'QTGateTest',
14191411
attachments: [{
14201412
content: text
@@ -1761,9 +1753,9 @@ class ImapConnect extends Imap.imapPeer {
17611753
}
17621754
if (!this.localServer.proxyServer || !this.localServer.connectCommand) {
17631755
saveLog(`got Command from server "changeDocker" localServer.proxyServer or localServer.connectCommand is null!!`);
1764-
container[0].localServerIp = exports.getLocalInterface()[0];
1765-
return this.localServer.findPort(this.localServer.localProxyPort, (err, port) => {
1756+
return findPort(this.localServer.localProxyPort, (err, port) => {
17661757
container[0].localServerPort = this.localServer.localProxyPort = port;
1758+
container[0].localServerIp = exports.getLocalInterface()[0];
17671759
return this.localServer.makeOpnConnect(container);
17681760
});
17691761
}

0 commit comments

Comments
 (0)