From a9c85e00a260d595952c1a3a94222fcfee33cea8 Mon Sep 17 00:00:00 2001 From: FelisCatus Date: Tue, 14 Apr 2015 22:03:59 +0800 Subject: [PATCH] Add compatible PAC result for SOCKS5 in Safari. Fix #391. --- omega-pac/src/profiles.coffee | 5 ++++- omega-pac/test/profiles.coffee | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/omega-pac/src/profiles.coffee b/omega-pac/src/profiles.coffee index 3a68270..b89b5ed 100644 --- a/omega-pac/src/profiles.coffee +++ b/omega-pac/src/profiles.coffee @@ -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' diff --git a/omega-pac/test/profiles.coffee b/omega-pac/test/profiles.coffee index 5094fae..2e787c9 100644 --- a/omega-pac/test/profiles.coffee +++ b/omega-pac/test/profiles.coffee @@ -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')