Skip to content

Commit 00365b5

Browse files
Peter XiePeter Xie
authored andcommitted
v0.8.30
1 parent b6cd719 commit 00365b5

File tree

12 files changed

+137
-291
lines changed

12 files changed

+137
-291
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The excellent point is QTGATE exchanges data by email account, client and server
1111
這是 QTGATE 客戶端 install.
1212
QTGATE是一种安全通讯手段,通过eMail的IMAP协议建立一个虚拟的专用通道,连接客户端和代理服务器,它的奇妙之处在于客户端和服务器彼此不用知道相互的IP地址,而是通过共用一个eMail账号进行数据交换,QTGATE系统把VPN包加密后,利用IMAP进行通讯,能最大限度的保护您的网络通讯不被检测和干扰,建立一个私密的网络安全环境。
1313

14-
このプロジェクトはQTGATE端末用ソフトです.
14+
このプロジェクトはQTGATE端末用ソフトです.
1515
QTGATEとは、eMailの通信プロトコルIMAPを使用して、端末とサーバの間に、仮想のネットワークトンネルを構築し、さらにVPNをカプセル化にしたことで、どんな端末からも利用することができます。QTGATEの一番重要な特徴は,端末とサーバの通信がIPアドレスではなく、一つのeMailアカウントを使います。それによって世界中に安全と自由な通信ができるようになります。
1616
![http protocol](/resources/startScreen.jpg?raw=true)
1717

@@ -26,9 +26,9 @@ bozon package [mac|windows|linux]
2626

2727
## Notice 注意事項
2828

29-
This bate version only support http & https proxy
30-
當前版本只對應 http 和 https proxy
31-
このパージョンは http と https proxy しか対応していますので、ご注意してください。
29+
This bate version have not support UDP proxy
30+
當前版本UDP未對應
31+
このパージョンはUDP対応しておりませんので、ご注意してください。
3232

3333
## License 版權
3434

app/gateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const otherRequestForNet = ( path: string, host: string, port: number, UserAgent
4141
class hostLookupResponse extends Stream.Writable {
4242
constructor ( private CallBack: ( err?: Error, dns?: domainData ) => void ) { super ()}
4343
public _write ( chunk: Buffer, enc, next ) {
44-
console.log ( `hostLookupResponse _write come [${ chunk.toString()}]`)
44+
//console.log ( `hostLookupResponse _write come [${ chunk.toString()}]`)
4545
const ns = chunk.toString ( 'utf8' )
4646
try {
4747
const _ret = JSON.parse ( ns )

app/proxyServer.ts

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ const managerPagePort = 8001
4646

4747
const testGatewayDomainName = 'www.google.com'
4848

49-
// -
50-
const IsSslConnect = ( buffer: Buffer ) => {
51-
52-
const kk = buffer.toString ( 'hex', 0, 4 )
53-
54-
return /^1603(01|02|03|00)|^80..0103|^(14|15|17)03(00|01)/.test (kk)
55-
}
56-
5749
export const checkDomainInBlackList = ( BlackLisk: string[], domain: string, CallBack ) => {
5850

5951
if ( Net.isIP ( domain )) {
@@ -277,10 +269,8 @@ export const isAllBlackedByFireWall = ( hostName: string, ip6: boolean, gatway:
277269
}
278270

279271
const isSslFromBuffer = ( buffer ) => {
280-
console.log ( buffer.toString ('hex'))
281-
const ret = /^\x16[\x2c-\xff]\x01\x00[\x00-\x05].[\x00-\x09][\x00-\x1f]|^\x80[\x0f-\xff]\x01[\x00-\x09][\x00-\x1f][\x00-\x05].\x00.\x00./.test ( buffer )
282-
283-
console.log ( `ret [${ ret }]`)
272+
273+
const ret = /^\x16\x03|^\x80/.test ( buffer )
284274
return ret
285275
}
286276
const httpProxy = ( clientSocket: Net.Socket, buffer: Buffer, useGatWay: boolean, ip6: boolean, connectTimeOut: number,
@@ -351,6 +341,14 @@ const httpProxy = ( clientSocket: Net.Socket, buffer: Buffer, useGatWay: boolean
351341

352342
}
353343

344+
const getPac = ( hostIp: string, port: number ) => {
345+
346+
const FindProxyForURL = `function FindProxyForURL ( url, host ) { return SOCKS ${ hostIp }:${ port.toString() };}`
347+
348+
return res._HTTP_200 ( FindProxyForURL )
349+
}
350+
351+
354352
export class proxyServer {
355353

356354
private hostLocalIpv4: { network: string, address: string } []= []
@@ -399,40 +397,23 @@ export class proxyServer {
399397
})
400398

401399
}
402-
/*
403-
private getPac ( remoteIp: string, port: string ) {
404-
405-
const ip6 = Net.isIP ( remoteIp )
406-
const hostIp = Ip.isPrivate ( remoteIp ) ? ip6 === 6 ? this.hostLocalIpv6 : Nekudo.getLocalNetWorkIp ( this.hostLocalIpv4, remoteIp ) : ip6 === 6 ? this.hostGlobalIpV6: this.hostGlobalIpV4
407-
408-
const FindProxyForURL = `function FindProxyForURL ( url, host ) {return SOCKS5 ${ hostIp }:${ port };}`
409-
410-
return _HTTP_200 ( FindProxyForURL )
411-
}
412-
*/
413-
constructor ( public whiteIpList: string[], public domainListPool: Map < string, domainData >,
400+
401+
constructor ( public whiteIpList: string[], public domainListPool: Map < string, domainData >, private localProxyServerIP: string,
414402
private port: number, private securityPath: string, private serverIp: string, private serverPort: number, private password: string, public checkAgainTimeOut: number,
415403
public connectHostTimeOut: number, public useGatWay: boolean, public domainBlackList: string[] ) {
416404
this.getGlobalIp ( this.gateway )
417405
let socks = null
418406
const server = Net.createServer ( socket => {
419407
const ip = socket.remoteAddress
420408
const isWhiteIp = this.whiteIpList.find ( n => { return n === ip }) ? true : false
421-
422409
socket.once ( 'data', ( data: Buffer ) => {
423-
/*
424-
if ( ! isWhiteIp ) {
425-
console.log ('! isWhiteIp', data.toString ('utf8'))
426-
if ( testLogin ( data, this.securityPath )) {
427-
428-
this.whiteIpList.push ( ip )
429-
this.saveWhiteIpList ()
430-
return socket.end ( this.getPac ( ip, port.toString ()))
431-
}
432-
433-
return socket.end ()
410+
if ( /GET \/pac/.test ( data.toString())) {
411+
const ret = getPac ( this.localProxyServerIP, this.port )
412+
saveLog ( `/GET \/pac from :[${ socket.remoteAddress }]`)
413+
return socket.end ( ret )
434414
}
435-
*/
415+
416+
436417
switch ( data.readUInt8 ( 0 )) {
437418
case 0x4:
438419
socks = new Socks.sockt4 ( socket, data, this )
@@ -476,6 +457,7 @@ interface proxyServerInfo {
476457
allToGateway: boolean
477458
localPort: number
478459
}
460+
479461
let flag = 'w'
480462
const QTGateFolder = Path.join ( Os.homedir(), '.QTGate' )
481463
const proxyLogFile = Path.join ( QTGateFolder, 'proxy.log' )
@@ -489,7 +471,7 @@ const saveLog = ( log: string ) => {
489471

490472
remote.getCurrentWindow().once ( 'firstCallBack', ( data: IConnectCommand ) => {
491473
console.log ( data )
492-
const server = new proxyServer ([], new Map(), data.localServerPort, 'pac', data.gateWayIpAddress, data.gateWayPort, data.imapData.randomPassword,
474+
const server = new proxyServer ([], new Map(), data.localServerIp, data.localServerPort, 'pac', data.gateWayIpAddress, data.gateWayPort, data.imapData.randomPassword,
493475
5000, 50000, data.AllDataToGateway, [] )
494476

495477
})

app/public/scripts/home.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const getImapSmtpHost = (email) => {
5959
const ret = {
6060
imap: 'imap.' + domain,
6161
smtp: 'smtp.' + domain,
62-
SmtpPort: [587, 465],
62+
SmtpPort: [465],
6363
ImapPort: 993,
6464
imapSsl: true,
6565
smtpSsl: true,
@@ -142,6 +142,7 @@ const getImapSmtpHost = (email) => {
142142
{
143143
ret.imap = 'imap.mail.me.com';
144144
ret.smtp = 'smtp.mail.me.com';
145+
ret.SmtpPort = [587];
145146
}
146147
break;
147148
// 163.com
@@ -571,16 +572,16 @@ const infoDefine = [
571572
buttom1_2: 'QTGate团队',
572573
conformButtom: '验 证',
573574
formatError: [
574-
'内容格式错误,请复制从“-----BEGIN PGP MESSAGE----- (开始,一直到)-----END PGP MESSAGE-----” 结束的完整内容,粘贴在此输入框中。',
575-
'提供的内容不能被解密,请确认这是在您收到的最后一封从QTGate发送过来的激活信。如果还是没法完成激活,请删除您的密钥重新生成和设定。',
575+
'内容格式错误,请复制从“-----BEGIN PGP MESSAGE----- (开始,一直到)-----END PGP MESSAGE-----” 结束的完整内容,粘贴在此输入框中。 ',
576+
'提供的内容不能被解密,请确认这是在您收到的最后一封从QTGate发送过来的激活信。如果还是没法完成激活,请删除您的密钥重新生成和设定。 ',
576577
'和QTGate连接发生错误,请退出重新尝试! ',
577-
'无效激活码!QTGate系统已重新发送新的激活Email,并斷開與您的連接。请退出QTGate重新啟動QTGate後,检查您的邮箱重做激活。',
578-
'您的QTGate看上去有问题, 请删除您的密钥,重新设置您的QTGate!',
579-
'QTGate系统故障,请稍后再试。',
580-
'您当天的数据通讯量达到上限,请等待明天再试或升级用户类型', '用来通讯的Email设定有错误,请检查IMAP设定后重试,或此Email类型QTGate不支持',
578+
'无效激活码! QTGate系统已重新发送新的激活Email,并断开与您的连接。请退出QTGate重新启动QTGate后,检查您的邮箱重做激活。 ',
579+
'您的QTGate看上去有问题, 请删除您的密钥,重新设置您的QTGate! ',
580+
'QTGate系统故障,请稍后再试。 ',
581+
'您当天的数据通讯量达到上限,请等待明天再试或升级用户类型',
581582
'用来通讯的Email设定有错误,请检查IMAP设定后重试,或QTGate不支持此Email类型',
582583
'您所选区域不能够连结,请稍候再试',
583-
'您的IMAP邮箱发信发生错误。请退出QTGate重试。如果持续发生此故障,您的IMAP帐号有可能被锁住,需要登陆您的IMAP邮箱网站解锁操作。'
584+
'您的IMAP邮箱发信发生错误。请退出QTGate重试。如果持续发生此故障,您的IMAP帐号有可能被锁住,需要登陆您的IMAP邮箱网站解锁操作。 '
584585
],
585586
activeing: '正在通讯中'
586587
},

app/public/scripts/home.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const getImapSmtpHost = ( email: string ) => {
8686
const ret = {
8787
imap: 'imap.' + domain,
8888
smtp: 'smtp.' + domain,
89-
SmtpPort: [587,465],
89+
SmtpPort: [465],
9090
ImapPort: 993,
9191
imapSsl: true,
9292
smtpSsl: true,
@@ -172,7 +172,8 @@ const getImapSmtpHost = ( email: string ) => {
172172
case 'mac.com':
173173
case 'me.com': {
174174
ret.imap = 'imap.mail.me.com'
175-
ret.smtp = 'smtp.mail.me.com'
175+
ret.smtp = 'smtp.mail.me.com'
176+
ret.SmtpPort = [587]
176177

177178
}
178179
break;
@@ -628,16 +629,16 @@ const infoDefine = [
628629
buttom1_2: 'QTGate团队',
629630
conformButtom: '验 证',
630631
formatError: [
631-
'内容格式错误,请复制从“-----BEGIN PGP MESSAGE----- (开始,一直到)-----END PGP MESSAGE-----” 结束的完整内容,粘贴在此输入框中。',
632-
'提供的内容不能被解密,请确认这是在您收到的最后一封从QTGate发送过来的激活信。如果还是没法完成激活,请删除您的密钥重新生成和设定。',
633-
'和QTGate连接发生错误,请退出重新尝试! ',
634-
'无效激活码!QTGate系统已重新发送新的激活Email,并斷開與您的連接。请退出QTGate重新啟動QTGate後,检查您的邮箱重做激活。',
635-
'您的QTGate看上去有问题, 请删除您的密钥,重新设置您的QTGate!',
636-
'QTGate系统故障,请稍后再试。',
637-
'您当天的数据通讯量达到上限,请等待明天再试或升级用户类型','用来通讯的Email设定有错误,请检查IMAP设定后重试,或此Email类型QTGate不支持',
638-
'用来通讯的Email设定有错误,请检查IMAP设定后重试,或QTGate不支持此Email类型',
639-
'您所选区域不能够连结,请稍候再试',
640-
'您的IMAP邮箱发信发生错误。请退出QTGate重试。如果持续发生此故障,您的IMAP帐号有可能被锁住,需要登陆您的IMAP邮箱网站解锁操作。'
632+
'内容格式错误,请复制从“-----BEGIN PGP MESSAGE----- (开始,一直到)-----END PGP MESSAGE-----” 结束的完整内容,粘贴在此输入框中。 ',
633+
                '提供的内容不能被解密,请确认这是在您收到的最后一封从QTGate发送过来的激活信。如果还是没法完成激活,请删除您的密钥重新生成和设定。 ',
634+
                '和QTGate连接发生错误,请退出重新尝试! ',
635+
                '无效激活码! QTGate系统已重新发送新的激活Email,并断开与您的连接。请退出QTGate重新启动QTGate后,检查您的邮箱重做激活。 ',
636+
                '您的QTGate看上去有问题, 请删除您的密钥,重新设置您的QTGate! ',
637+
                'QTGate系统故障,请稍后再试。 ',
638+
                '您当天的数据通讯量达到上限,请等待明天再试或升级用户类型',
639+
                '用来通讯的Email设定有错误,请检查IMAP设定后重试,或QTGate不支持此Email类型',
640+
                '您所选区域不能够连结,请稍候再试',
641+
                '您的IMAP邮箱发信发生错误。请退出QTGate重试。如果持续发生此故障,您的IMAP帐号有可能被锁住,需要登陆您的IMAP邮箱网站解锁操作。 '
641642
],
642643
activeing: '正在通讯中'
643644
},

0 commit comments

Comments
 (0)