Skip to content

Commit c32a28f

Browse files
Peter XiePeter Xie
authored andcommitted
v0.8.59
1 parent 1dacc8e commit c32a28f

File tree

10 files changed

+37
-20
lines changed

10 files changed

+37
-20
lines changed

app/httpProxy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export default class httpProxy {
100100
return /^port/i.test ( this.commandWithLine[0] )
101101
}
102102

103+
get host () {
104+
return this.headers['host'].split(':')[0]
105+
}
106+
103107
get cachePath () {
104108
if ( !this.isGet || ! this.isCanCacheFile )
105109
return null

app/proxyServer.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,11 @@ const getPac = ( hostIp: string, port: number, http: boolean, sock5: boolean ) =
366366
isInNet ( dnsResolve( host ), "10.0.0.0", "255.0.0.0" )) {
367367
return "DIRECT";
368368
}
369-
return "${ http ? 'PROXY': ( sock5 ? 'SOCKS5' : 'SOCKS' ) } ${ hostIp }:${ port.toString() }";
370-
}`
369+
return "${ http ? 'PROXY': ( sock5 ? 'SOCKS5' : 'SOCKS' ) } ${ hostIp }:${ port.toString() }";
371370
372-
return res._HTTP_200 ( FindProxyForURL )
371+
}`
372+
//return "${ http ? 'PROXY': ( sock5 ? 'SOCKS5' : 'SOCKS' ) } ${ hostIp }:${ port.toString() }; ";
373+
return res.Http_Pac ( FindProxyForURL )
373374
}
374375

375376

@@ -436,13 +437,13 @@ export class proxyServer {
436437
if ( /^GET \/pac/.test ( dataStr )) {
437438
const httpHead = new HttpProxyHeader ( data )
438439
agent = httpHead.headers['user-agent']
439-
const sock5 = /Windows NT|Darwin|Firefox/i.test ( agent ) && ! /CFNetwork/i.test (agent)
440+
const sock5 = /Windows NT|Darwin|Firefox/i.test ( agent ) && ! /CFNetwork|WOW64/i.test ( agent )
441+
440442

441-
let ret = getPac ( this.localProxyServerIP, this.port, false, sock5 )
442-
if ( /pacHttp/.test( dataStr ))
443-
ret = getPac ( this.localProxyServerIP, this.port, true, sock5 )
443+
const ret = getPac ( httpHead.host, this.port, /pacHttp/.test( dataStr ), sock5 )
444444
console.log ( `/GET \/pac from :[${ socket.remoteAddress }] sock5 [${ sock5 }] agent [${ agent }] httpHead.headers [${ Object.keys(httpHead.headers)}]`)
445445
console.log ( dataStr )
446+
console.log ( ret )
446447
return socket.end ( ret )
447448
}
448449

app/public/css/pages.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ h1>.badge, h2>.badge, h3>.badge, h4>.badge,h5>.badge,h6>.badge {
480480
}
481481
.WindowsUseInfoLocalServerIp {
482482
position: relative;
483-
left: 13.2em;
484-
top: 15.5em;
483+
left: 10.4em;
484+
top: 12.5em;
485485
color: blue;
486486
}
487487
.WindowsUseInfoPort{
99.9 KB
Loading

app/public/scripts/home.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ const infoDefine = [
735735
}, {
736736
title: '选择自动设置代理服务器',
737737
titleImage: '',
738-
detail: '<p>在URL网址处填入:使用HTTP和HTTPS代理请按照蓝色第一行填入,使用SOCKS代理选择蓝色第二行</p>',
738+
detail: '<p>WINDOWS10系统只对应HTTP和HTTPS,如果想使用全局代理的用户,需另外安装浏览器如火狐等,然后在火狐浏览器内单独设定Proxy全局代理SOCKS</p>',
739739
image: '/images/windowsUseInfo4.jpg'
740740
}]
741741
},
@@ -834,7 +834,7 @@ const infoDefine = [
834834
}, {
835835
title: '自動プロキシをオンに',
836836
titleImage: '',
837-
detail: '<p>下の入力にHTTPとHTTPSは上のブルー行を、SOCKSは下の行を入力して保存をして終了します。</p>',
837+
detail: '<p>WINDOWS 10 システムはHTTPとHTTPSしかサポートしておりませんが、SOCKSを使うなら、他のブラウザ例えばFireFoxなどをインストールによりお使いは可能です。</p>',
838838
image: '/images/windowsUseInfo4.jpg'
839839
}]
840840
},
@@ -1328,7 +1328,7 @@ const infoDefine = [
13281328
}, {
13291329
title: 'Open Use a proxy server, On Use setup script.',
13301330
titleImage: '',
1331-
detail: '<p>HTTP and HTTPS proxy please same as the top blue line, SOCKS proxy is the bottom line.</p>',
1331+
detail: '<p>Windows 10 system support HTTP & HTTPS proxy only, SOCKS user need install other browser like Firefox, then setup the SOCKS PROXY in Firefox.',
13321332
image: '/images/windowsUseInfo4.jpg'
13331333
}]
13341334
},
@@ -1678,7 +1678,7 @@ const infoDefine = [
16781678
}, {
16791679
title: '選擇自動設置代理伺服器。',
16801680
titleImage: '',
1681-
detail: '<p>HTTP和HTTPS代理按照藍色第一行填入,SOCKS代理按藍色第二行填入</p>',
1681+
detail: '<p>WINDOWS10系統只對應HTTP和HTTPS,如果想使用全局代理的用戶,需另外安裝瀏覽器如火狐等,然後在火狐瀏覽器內單獨設定Proxy全局代理SOCKS</p>',
16821682
image: '/images/windowsUseInfo4.jpg'
16831683
}]
16841684
},

app/public/scripts/home.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ const infoDefine = [
794794
},{
795795
title:'选择自动设置代理服务器',
796796
titleImage:'',
797-
detail:'<p>在URL网址处填入:使用HTTP和HTTPS代理请按照蓝色第一行填入,使用SOCKS代理选择蓝色第二行</p>',
797+
detail:'<p>WINDOWS10系统只对应HTTP和HTTPS,如果想使用全局代理的用户,需另外安装浏览器如火狐等,然后在火狐浏览器内单独设定Proxy全局代理SOCKS</p>',
798798
image: '/images/windowsUseInfo4.jpg'
799799
}]
800800
},
@@ -899,7 +899,7 @@ const infoDefine = [
899899
},{
900900
title:'自動プロキシをオンに',
901901
titleImage:'',
902-
detail:'<p>下の入力にHTTPとHTTPSは上のブルー行を、SOCKSは下の行を入力して保存をして終了します。</p>',
902+
detail:'<p>WINDOWS 10 システムはHTTPとHTTPSしかサポートしておりませんが、SOCKSを使うなら、他のブラウザ例えばFireFoxなどをインストールによりお使いは可能です。</p>',
903903
image: '/images/windowsUseInfo4.jpg'
904904
}]
905905
},
@@ -1407,7 +1407,7 @@ const infoDefine = [
14071407
},{
14081408
title:'Open Use a proxy server, On Use setup script.',
14091409
titleImage:'',
1410-
detail:'<p>HTTP and HTTPS proxy please same as the top blue line, SOCKS proxy is the bottom line.</p>',
1410+
detail:'<p>Windows 10 system support HTTP & HTTPS proxy only, SOCKS user need install other browser like Firefox, then setup the SOCKS PROXY in Firefox.',
14111411
image: '/images/windowsUseInfo4.jpg'
14121412
}]
14131413
},
@@ -1774,7 +1774,7 @@ const infoDefine = [
17741774
},{
17751775
title:'選擇自動設置代理伺服器。',
17761776
titleImage:'',
1777-
detail:'<p>HTTP和HTTPS代理按照藍色第一行填入,SOCKS代理按藍色第二行填入</p>',
1777+
detail:'<p>WINDOWS10系統只對應HTTP和HTTPS,如果想使用全局代理的用戶,需另外安裝瀏覽器如火狐等,然後在火狐瀏覽器內單獨設定Proxy全局代理SOCKS</p>',
17781778
image: '/images/windowsUseInfo4.jpg'
17791779
}]
17801780
},

app/res.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ Cache-Control: private, max-age=0
5353
5454
${ _HTTP_598_body }
5555
`
56+
export const Http_Pac = ( body: string ) => {
57+
return `HTTP/1.1 200 OK
58+
Content-Type: application/x-ns-proxy-autoconfig
59+
Connection: keep-alive
60+
Content-Length: ${ body.length }
5661
62+
${ body }\r\n\r\n`
63+
}
5764
export const _HTTP_200 = ( body: string ) => {
5865
return `HTTP/1.1 200 OK
5966
Content-Type: text/html; charset=UTF-8

app/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ const doUrlWithIp = (url, dns, CallBack) => {
106106
.once('error', CallBack);
107107
};
108108
const getMyLocalIpAddress = (server, CallBack) => {
109+
saveLog(JSON.stringify(server));
109110
let ret = false;
110111
Async.each(server, (n, next) => {
111112
doUrlWithIp(n.url, n.dnsName, (err, data) => {
@@ -714,9 +715,10 @@ class localServer {
714715
};
715716
if (cmd.connectType === 2) {
716717
return getMyLocalIpAddress(this.myIpServer, (err, data) => {
718+
saveLog(`getMyLocalIpAddress callback err [${JSON.stringify(err)}] data [${JSON.stringify(data)}]`);
717719
cmd.imapData.clientIpAddress = data;
718720
saveLog(JSON.stringify(cmd));
719-
//return request ()
721+
return request();
720722
});
721723
}
722724
return request();

app/server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const doUrlWithIp = ( url: string, dns: string, CallBack ) => {
123123
}
124124

125125
const getMyLocalIpAddress = ( server: QTGate_DnsAddress[], CallBack ) => {
126+
saveLog ( JSON.stringify (server))
126127
let ret = false
127128
Async.each ( server, ( n: QTGate_DnsAddress, next ) => {
128129
doUrlWithIp ( n.url, n.dnsName, ( err, data ) => {
@@ -771,11 +772,13 @@ export class localServer {
771772
saveLog ( `res.error [${ res.error }]`)
772773
})
773774
}
775+
774776
if ( cmd.connectType === 2 ) {
775777
return getMyLocalIpAddress ( this.myIpServer, ( err, data ) => {
778+
saveLog ( `getMyLocalIpAddress callback err [${ JSON.stringify ( err ) }] data [${ JSON.stringify ( data )}]`)
776779
cmd.imapData.clientIpAddress = data
777780
saveLog ( JSON.stringify ( cmd ))
778-
//return request ()
781+
return request ()
779782
})
780783

781784
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qtgate",
3-
"version": "0.8.56",
3+
"version": "0.8.59",
44
"license": "MIT",
55
"description": "QTGate desktop client",
66
"scripts": {

0 commit comments

Comments
 (0)