Skip to content

Commit 34fc58d

Browse files
Peter XiePeter Xie
authored andcommitted
v1.0.1
1 parent a9b9bc4 commit 34fc58d

File tree

11 files changed

+191
-184
lines changed

11 files changed

+191
-184
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QTGATE client - Open Source
22
[![Build Status](https://travis-ci.org/QTGate/QTGate-Desktop-Client.svg?branch=master)](https://travis-ci.org/QTGate/QTGate-Desktop-Client)
33
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-blue.svg)](https://gitter.im/QTGate/Lobby)
4-
4+
[![Known Vulnerabilities](https://snyk.io/test/github/qtgate/qtgate-desktop-client/badge.svg)](https://snyk.io/test/github/qtgate/qtgate-desktop-client)
55
## Description 概要
66

77
This is QTGATE client software install build

app/imap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ export class qtGateImap extends Event.EventEmitter {
910910
saveLog (`jj.once ( 'error' ) listenFolder[${ this.listenFolder }] writeFolder [${ this.writeFolder }]`)
911911
this.destroyAll ( err )
912912
})
913+
913914
jj.once ( 'end', () => {
914915
saveLog (`jj.once ( 'end' ) listenFolder[${ this.listenFolder }] writeFolder [${ this.writeFolder }]`)
915916
this.destroyAll ( null )

app/public/scripts/home.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ const infoDefine = [
576576
emailConform: {
577577
activeViewTitle: '验证您的密钥',
578578
info1_1: `您的密钥还未完成验证,QTGate已向您的密钥邮箱发送了一封加密邮件,请检查您的 【`,
579-
info1_2: `】 邮箱。如果存在多封从QTGate过来的邮件时,以最后一封为准,打开信件并复制邮件内容。`,
579+
info1_2: `】 邮箱。如果存在多封QTGate的邮件时,请选择最后一封信件。请打开信件并复制邮件内容。如果您还未收到QTGate的邮件,请检查您的密钥邮箱是否准确,或者您可以删除您现有的密钥,重新生成新密钥。`,
580580
info2: '请复制从“-----BEGIN PGP MESSAGE----- (开始,一直到)-----END PGP MESSAGE-----” 结束的完整内容,粘贴在此输入框中。',
581581
emailTitle: '感谢您使用QTGate服务',
582582
emailDetail1: '尊敬的 ',
@@ -1155,7 +1155,7 @@ const infoDefine = [
11551155
emailConform: {
11561156
activeViewTitle: '鍵ペア検証',
11571157
info1_1: `鍵ペア検証は未完成です。QTGateは宛先 「`,
1158-
info1_2: `」 に検証メールをしました。メールボックスをチェックしてください。QTGateから多数メールの場合は、最後のを選んでください。`,
1158+
info1_2: `」 に検証メールをしました。メールボックスをチェックしてください。QTGateから多数メールの場合は、最後のを選んでください。QTGateからのメールが見つからない場合は鍵ペアを生成するメールアドレスを正しいかどうかダブチェックしてください。または鍵ペアを削除して新しい鍵ペアを再作成をしてください。`,
11591159
info2: 'コピーするのは「-----BEGIN PGP MESSAGE-----」から「-----END PGP MESSAGE-----」まで全ての内容をしてください。',
11601160
emailTitle: 'QTGateをご利用頂いて誠に有難うございます',
11611161
emailDetail1: '',
@@ -1630,7 +1630,7 @@ const infoDefine = [
16301630
activeViewTitle: 'Active your keypair.',
16311631
emailTitle: 'Welcome to QTGate.',
16321632
info1_1: 'Key pair verification is not complete. A verification email from QTGate has been sent. Please check your [',
1633-
info1_2: '] mailbox. If you have one more then one mail from QTGate in your mailbox, please choose the newest one.',
1633+
info1_2: '] mailbox. If you have one more then one mail from QTGate in your mailbox, please choose the newest one. If you not find the email, please double check your key pair email address! You may delete your key pair and generate a new key pair. ',
16341634
info2: 'Copy all content from [-----BEGIN PGP MESSAGE-----] ... to [-----END PGP MESSAGE-----]. Paste into this text box.',
16351635
emailDetail1: 'Dear ',
16361636
emailDetail1_1: ' ,',
@@ -2080,7 +2080,7 @@ const infoDefine = [
20802080
activeViewTitle: '驗證您的密鑰',
20812081
emailTitle: '感謝您使用QTGate服務',
20822082
info1_1: '您的密鑰還未完成驗證,QTGate已向您的密鑰郵箱發送了一封加密郵件,請檢查您的【',
2083-
info1_2: '】郵箱。如果存在多封從QTGate過來的郵件時,以最後一封為準,打開信件並複制郵件。',
2083+
info1_2: '】郵箱。如果存在多封QTGate的郵件時,請選擇最後一封信件。請打開信件並複制郵件內容。如果您還未收到QTGate的郵件,請檢查您的密鑰郵箱是否準確,或者您可以刪除您現有的密鑰,重新生成新的密鑰。',
20842084
info2: '複制內容從“-----BEGIN PGP MESSAGE----- ( 開始,一直到 )----- END PGP MESSAGE-----” 結束的完整內容,粘貼到此輸入框中',
20852085
emailDetail1: '尊敬的 ',
20862086
emailDetail1_1: '',

app/public/scripts/home.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ const infoDefine = [
631631
emailConform: {
632632
activeViewTitle:'验证您的密钥',
633633
info1_1: `您的密钥还未完成验证,QTGate已向您的密钥邮箱发送了一封加密邮件,请检查您的 【`,
634-
info1_2: `】 邮箱。如果存在多封从QTGate过来的邮件时,以最后一封为准,打开信件并复制邮件内容。`,
634+
info1_2: `】 邮箱。如果存在多封QTGate的邮件时,请选择最后一封信件。请打开信件并复制邮件内容。如果您还未收到QTGate的邮件,请检查您的密钥邮箱是否准确,或者您可以删除您现有的密钥,重新生成新密钥。`,
635635
info2: '请复制从“-----BEGIN PGP MESSAGE----- (开始,一直到)-----END PGP MESSAGE-----” 结束的完整内容,粘贴在此输入框中。',
636636
emailTitle: '感谢您使用QTGate服务',
637637
emailDetail1: '尊敬的 ',
@@ -1238,7 +1238,7 @@ const infoDefine = [
12381238
emailConform: {
12391239
activeViewTitle:'鍵ペア検証',
12401240
info1_1:`鍵ペア検証は未完成です。QTGateは宛先 「`,
1241-
info1_2: `」 に検証メールをしました。メールボックスをチェックしてください。QTGateから多数メールの場合は、最後のを選んでください。`,
1241+
info1_2: `」 に検証メールをしました。メールボックスをチェックしてください。QTGateから多数メールの場合は、最後のを選んでください。QTGateからのメールが見つからない場合は鍵ペアを生成するメールアドレスを正しいかどうかダブチェックしてください。または鍵ペアを削除して新しい鍵ペアを再作成をしてください。`,
12421242
info2: 'コピーするのは「-----BEGIN PGP MESSAGE-----」から「-----END PGP MESSAGE-----」まで全ての内容をしてください。',
12431243
emailTitle: 'QTGateをご利用頂いて誠に有難うございます',
12441244
emailDetail1: '',
@@ -1747,7 +1747,7 @@ const infoDefine = [
17471747
activeViewTitle: 'Active your keypair.',
17481748
emailTitle: 'Welcome to QTGate.',
17491749
info1_1: 'Key pair verification is not complete. A verification email from QTGate has been sent. Please check your [',
1750-
info1_2: '] mailbox. If you have one more then one mail from QTGate in your mailbox, please choose the newest one.',
1750+
info1_2: '] mailbox. If you have one more then one mail from QTGate in your mailbox, please choose the newest one. If you not find the email, please double check your key pair email address! You may delete your key pair and generate a new key pair. ',
17511751
info2: 'Copy all content from [-----BEGIN PGP MESSAGE-----] ... to [-----END PGP MESSAGE-----]. Paste into this text box.',
17521752
emailDetail1: 'Dear ',
17531753
emailDetail1_1: ' ,',
@@ -2223,7 +2223,7 @@ const infoDefine = [
22232223
activeViewTitle:'驗證您的密鑰',
22242224
emailTitle: '感謝您使用QTGate服務',
22252225
info1_1: '您的密鑰還未完成驗證,QTGate已向您的密鑰郵箱發送了一封加密郵件,請檢查您的【',
2226-
info1_2: '】郵箱。如果存在多封從QTGate過來的郵件時,以最後一封為準,打開信件並複制郵件。',
2226+
info1_2: '】郵箱。如果存在多封QTGate的郵件時,請選擇最後一封信件。請打開信件並複制郵件內容。如果您還未收到QTGate的郵件,請檢查您的密鑰郵箱是否準確,或者您可以刪除您現有的密鑰,重新生成新的密鑰。',
22272227
info2: '複制內容從“-----BEGIN PGP MESSAGE----- ( 開始,一直到 )----- END PGP MESSAGE-----” 結束的完整內容,粘貼到此輸入框中',
22282228
emailDetail1: '尊敬的 ',
22292229
emailDetail1_1: '',

app/server.js

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const freePort = require("portastic");
3131
const Stream = require("stream");
3232
//import * as Ping from 'net-ping'
3333
const buffer_1 = require("buffer");
34+
const timers_1 = require("timers");
3435
const openpgp = require('openpgp');
3536
const Express = require('express');
3637
const cookieParser = require('cookie-parser');
@@ -655,7 +656,8 @@ class localServer {
655656
requestSerial: Crypto1.randomBytes(8).toString('hex')
656657
};
657658
return this.QTClass.request(com, (err, res) => {
658-
this.config.freeUser = /free/i.test(res.dataTransfer.productionPackage);
659+
if (res && res.dataTransfer && res.dataTransfer.productionPackage)
660+
this.config.freeUser = /free/i.test(res.dataTransfer.productionPackage);
659661
CallBack(res.Args[0], res.dataTransfer, this.config);
660662
saveLog(`getAvaliableRegion ${JSON.stringify(res)} `);
661663
// Have gateway connect!
@@ -675,32 +677,35 @@ class localServer {
675677
});
676678
socket.on('pingCheck', CallBack => {
677679
if (process.platform === 'linux')
678-
return CallBack(new Error('not support'));
679-
saveLog(`socket.on ( 'pingCheck' )`);
680-
if (!this.regionV1 || this.pingChecking) {
681-
saveLog(`!this.regionV1 [${!this.regionV1}] || this.pingChecking [${this.pingChecking}]`);
682-
return CallBack();
680+
return CallBack(-1);
681+
/*
682+
saveLog (`socket.on ( 'pingCheck' )`)
683+
if ( !this.regionV1 || this.pingChecking ) {
684+
saveLog (`!this.regionV1 [${ !this.regionV1 }] || this.pingChecking [${ this.pingChecking }]`)
685+
return CallBack()
683686
}
684-
this.pingChecking = true;
687+
688+
this.pingChecking = true
685689
try {
686-
const netPing = require('net-ping');
687-
const session = netPing.createSession();
688-
}
689-
catch (ex) {
690-
console.log(`netPing.createSession err`, ex);
691-
return CallBack(-1);
690+
const netPing = require ('net-ping')
691+
const session = netPing.createSession ()
692+
} catch (ex) {
693+
console.log (`netPing.createSession err`, ex )
694+
return CallBack ( -1 )
692695
}
693-
Async.eachSeries(this.regionV1, (n, next) => {
694-
return testPing(n.testHostIp, (err, ping) => {
695-
saveLog(`testPing [${n.regionName}] return ping [${ping}]`);
696-
socket.emit('pingCheck', n.regionName, err ? 9999 : ping);
697-
return next();
698-
});
696+
Async.eachSeries ( this.regionV1, ( n: regionV1, next ) => {
697+
698+
return testPing ( n.testHostIp, ( err, ping ) => {
699+
saveLog( `testPing [${ n.regionName }] return ping [${ ping }]`)
700+
socket.emit ( 'pingCheck', n.regionName, err? 9999: ping )
701+
return next ()
702+
})
699703
}, () => {
700-
saveLog(`pingCheck success!`);
701-
this.pingChecking = false;
702-
return CallBack();
703-
});
704+
saveLog (`pingCheck success!`)
705+
this.pingChecking = false
706+
return CallBack ()
707+
})
708+
*/
704709
});
705710
socket.once('downloadCheck', CallBack => {
706711
if (!this.regionV1)
@@ -1539,6 +1544,7 @@ const findQTGateImap = (imapPool) => {
15391544
});
15401545
};
15411546
const sentRequestMailWaitTimeOut = 1000 * 60 * 1.5;
1547+
const commandRequestTimeOutTime = 1000 * 30;
15421548
class ImapConnect extends Imap.imapPeer {
15431549
constructor(imapData, qtGateConnectEmitData, timeOutSendRequestMail, localServer, password, _exit, socket) {
15441550
super(imapData, imapData.clientFolder, imapData.serverFolder, (text, CallBack) => {
@@ -1613,12 +1619,13 @@ class ImapConnect extends Imap.imapPeer {
16131619
}
16141620
}
16151621
}
1616-
const CallBack = this.commandCallBackPool.get(ret.requestSerial);
1617-
if (!CallBack || typeof CallBack !== 'function') {
1622+
const poolData = this.commandCallBackPool.get(ret.requestSerial);
1623+
if (!poolData || typeof poolData.CallBack !== 'function') {
16181624
return saveLog(`QTGateAPIRequestCommand got commandCallBackPool ret.requestSerial [${ret.requestSerial}] have not callback `);
16191625
}
1626+
timers_1.clearTimeout(poolData.timeOut);
16201627
saveLog(`QTGateAPIRequestCommand got [${ret.requestSerial}] callback`);
1621-
return CallBack(null, ret);
1628+
return poolData.CallBack(null, ret);
16221629
};
16231630
}
16241631
errNumber(err) {
@@ -1658,15 +1665,15 @@ class ImapConnect extends Imap.imapPeer {
16581665
*/
16591666
makeTimeOutEvent() {
16601667
saveLog(`doing makeTimeOutEvent`);
1661-
clearTimeout(this.timeOutWhenSendConnectRequestMail);
1662-
return this.timeOutWhenSendConnectRequestMail = setTimeout(() => {
1668+
timers_1.clearTimeout(this.timeOutWhenSendConnectRequestMail);
1669+
return this.timeOutWhenSendConnectRequestMail = timers_1.setTimeout(() => {
16631670
saveLog('timeOutWhenSendConnectRequestMail UP!');
16641671
this.socket.emit('checkActiveEmailError', 2);
16651672
}, sentRequestMailWaitTimeOut);
16661673
}
16671674
doSendConnectMail() {
16681675
saveLog(`doSendConnectMail`);
1669-
clearTimeout(this.timeOutWhenSendConnectRequestMail);
1676+
timers_1.clearTimeout(this.timeOutWhenSendConnectRequestMail);
16701677
//this.clearServerListenFolder ()
16711678
return this.localServer.sendEmailTest(this.imapData, err => {
16721679
if (err) {
@@ -1681,8 +1688,15 @@ class ImapConnect extends Imap.imapPeer {
16811688
}
16821689
request(command, CallBack) {
16831690
saveLog(`request command [${command.command}] requestSerial [${command.requestSerial}]`);
1684-
if (command.requestSerial)
1685-
this.commandCallBackPool.set(command.requestSerial, CallBack);
1691+
if (command.requestSerial) {
1692+
const poolData = {
1693+
CallBack: CallBack,
1694+
timeOut: timers_1.setTimeout(() => {
1695+
return CallBack(new Error('timeout'));
1696+
}, commandRequestTimeOutTime)
1697+
};
1698+
this.commandCallBackPool.set(command.requestSerial, poolData);
1699+
}
16861700
return this._enCrypto(JSON.stringify(command), (err1, data) => {
16871701
if (err1) {
16881702
saveLog(`request _deCrypto got error [${JSON.stringify(err1)}]`);
@@ -1700,7 +1714,7 @@ class ImapConnect extends Imap.imapPeer {
17001714
return this.once('ready', () => {
17011715
CallBack();
17021716
saveLog('ImapConnect got response from QTGate imap server, connect ready!');
1703-
clearTimeout(this.timeOutWhenSendConnectRequestMail);
1717+
timers_1.clearTimeout(this.timeOutWhenSendConnectRequestMail);
17041718
this.QTGateServerready = true;
17051719
this.imapData.canDoDelete = false;
17061720
this.qtGateConnectEmitData.qtGateConnecting = 2;
@@ -1723,31 +1737,36 @@ class ImapConnect extends Imap.imapPeer {
17231737
return this.doReady(socket, () => { });
17241738
}
17251739
}
1726-
const testPing = (hostIp, CallBack) => {
1727-
let pingTime = 0;
1728-
const test = new Array(testPingTimes);
1729-
test.fill(hostIp);
1730-
saveLog(`start testPing [${hostIp}]`);
1731-
return Async.eachSeries(test, (n, next) => {
1732-
const netPing = require('net-ping');
1733-
const session = netPing.createSession();
1734-
session.pingHost(hostIp, (err, target, sent, rcvd) => {
1735-
session.close();
1736-
if (err) {
1737-
saveLog(`session.pingHost ERROR, ${err.message}`);
1738-
return next(err);
1740+
/*
1741+
const testPing = ( hostIp: string, CallBack ) => {
1742+
let pingTime = 0
1743+
const test = new Array ( testPingTimes )
1744+
test.fill ( hostIp )
1745+
saveLog (`start testPing [${ hostIp }]`)
1746+
return Async.eachSeries ( test, ( n, next ) => {
1747+
const netPing = require ('net-ping')
1748+
const session = netPing.createSession ()
1749+
session.pingHost ( hostIp, ( err, target, sent, rcvd ) => {
1750+
1751+
session.close ()
1752+
if ( err ) {
1753+
saveLog (`session.pingHost ERROR, ${ err.message }`)
1754+
return next ( err )
17391755
}
1740-
const ping = rcvd.getTime() - sent.getTime();
1741-
pingTime += ping;
1742-
return next();
1743-
});
1756+
const ping = rcvd.getTime () - sent.getTime ()
1757+
pingTime += ping
1758+
return next ()
1759+
})
17441760
}, err => {
1745-
if (err) {
1746-
return CallBack(new Error('ping error'));
1761+
if ( err ) {
1762+
return CallBack ( new Error ('ping error'))
17471763
}
1748-
return CallBack(null, Math.round(pingTime / testPingTimes));
1749-
});
1750-
};
1764+
1765+
return CallBack ( null, Math.round ( pingTime/testPingTimes ))
1766+
})
1767+
1768+
}
1769+
*/
17511770
const makeFeedBackDataToQTGateAPIRequestCommand = (data, Callback) => {
17521771
const ret = {
17531772
command: 'feedBackData',

0 commit comments

Comments
 (0)