Add compatible PAC result for SOCKS5 in Safari. Fix #391.

This commit is contained in:
FelisCatus 2015-04-14 22:03:59 +08:00
parent 9d91588dbb
commit a9c85e00a2
2 changed files with 8 additions and 1 deletions

View File

@ -62,7 +62,10 @@ module.exports = exports =
pacResult: (proxy) ->
if proxy
"#{exports.pacProtocols[proxy.scheme]} #{proxy.host}:#{proxy.port}"
if proxy.scheme == 'socks5'
"SOCKS5 #{proxy.host}:#{proxy.port}; SOCKS #{proxy.host}:#{proxy.port}"
else
"#{exports.pacProtocols[proxy.scheme]} #{proxy.host}:#{proxy.port}"
else
'DIRECT'

View File

@ -46,6 +46,10 @@ describe 'Profiles', ->
it 'should return a valid PAC result for a proxy', ->
proxy = {scheme: "http", host: "127.0.0.1", port: 8888}
Profiles.pacResult(proxy).should.equal("PROXY 127.0.0.1:8888")
it 'should return special compatible result for SOCKS5', ->
proxy = {scheme: "socks5", host: "127.0.0.1", port: 8888}
compatibleResult = "SOCKS5 127.0.0.1:8888; SOCKS 127.0.0.1:8888"
Profiles.pacResult(proxy).should.equal(compatibleResult)
describe '#byName', ->
it 'should get profiles from builtin profiles', ->
profile = Profiles.byName('direct')