mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -05:00
Use object return types when possible on Firefox with auth. Fix #1172.
This commit is contained in:
parent
b1c261c39c
commit
06e7ad67f0
@ -257,10 +257,20 @@ module.exports = exports =
|
|||||||
if profile.bypassList
|
if profile.bypassList
|
||||||
for cond in profile.bypassList
|
for cond in profile.bypassList
|
||||||
if Conditions.match(cond, request)
|
if Conditions.match(cond, request)
|
||||||
return [@pacResult(), cond]
|
return [@pacResult(), cond, {scheme: 'direct'}, null]
|
||||||
for s in @schemes when s.scheme == request.scheme and profile[s.prop]
|
for s in @schemes when s.scheme == request.scheme and profile[s.prop]
|
||||||
return [@pacResult(profile[s.prop]), s.scheme]
|
return [
|
||||||
return [@pacResult(profile.fallbackProxy), '']
|
@pacResult(profile[s.prop]),
|
||||||
|
s.scheme,
|
||||||
|
profile[s.prop],
|
||||||
|
profile.auth?[s.prop] ? profile.auth?['all']
|
||||||
|
]
|
||||||
|
return [
|
||||||
|
@pacResult(profile.fallbackProxy),
|
||||||
|
'',
|
||||||
|
profile.fallbackProxy,
|
||||||
|
profile.auth?.fallbackProxy ? profile.auth?['all']
|
||||||
|
]
|
||||||
compile: (profile) ->
|
compile: (profile) ->
|
||||||
if ((not profile.bypassList or not profile.fallbackProxy) and
|
if ((not profile.bypassList or not profile.fallbackProxy) and
|
||||||
not profile.proxyForHttp and not profile.proxyForHttps and
|
not profile.proxyForHttp and not profile.proxyForHttps and
|
||||||
|
@ -35,18 +35,35 @@ FindProxyForURL = (function () {
|
|||||||
|
|
||||||
if (Array.isArray(matchResult)) {
|
if (Array.isArray(matchResult)) {
|
||||||
next = matchResult[0];
|
next = matchResult[0];
|
||||||
// TODO: Maybe also return user/pass if Mozilla supports it or it ends
|
var proxy = matchResult[2];
|
||||||
// up standardized in WebExtensions in the future.
|
var auth = matchResult[3];
|
||||||
// MOZ: Mozilla has a bug tracked for user/pass in PAC return value.
|
if (proxy && !state.useLegacyStringReturn) {
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1319641
|
var proxyInfo = {
|
||||||
if (next.charCodeAt(0) !== 43) {
|
type: proxy.scheme,
|
||||||
|
host: proxy.host,
|
||||||
|
port: proxy.port,
|
||||||
|
};
|
||||||
|
if (proxyInfo.type === 'socks5') {
|
||||||
|
// MOZ: SOCKS5 proxies are identified by "type": "socks".
|
||||||
|
// https://dxr.mozilla.org/mozilla-central/rev/ffe6cc09ccf38cca6f0e727837bbc6cb722d1e71/toolkit/components/extensions/ProxyScriptContext.jsm#51
|
||||||
|
proxyInfo.type = 'socks';
|
||||||
|
// Enable SOCKS5 remote DNS.
|
||||||
|
// TODO(catus): Maybe allow the users to configure this?
|
||||||
|
proxyInfo.proxyDNS = true;
|
||||||
|
}
|
||||||
|
if (auth) {
|
||||||
|
proxyInfo.username = auth.username;
|
||||||
|
proxyInfo.password = auth.password;
|
||||||
|
}
|
||||||
|
return [proxyInfo];
|
||||||
|
} else if (next.charCodeAt(0) !== 43) {
|
||||||
|
// MOZ: Legacy proxy support expects PAC-like string return type.
|
||||||
|
// TODO(catus): Remove support for string return type.
|
||||||
// MOZ: SOCKS5 proxies are supported under the prefix SOCKS.
|
// MOZ: SOCKS5 proxies are supported under the prefix SOCKS.
|
||||||
// https://dxr.mozilla.org/mozilla-central/source/toolkit/components/extensions/ProxyScriptContext.jsm#178
|
// https://dxr.mozilla.org/mozilla-central/rev/ffe6cc09ccf38cca6f0e727837bbc6cb722d1e71/toolkit/components/extensions/ProxyScriptContext.jsm#51
|
||||||
// Note: We have to replace this because MOZ won't process the rest of
|
// Note: We have to replace this because MOZ won't process the rest of
|
||||||
// the list if the syntax of the first item is not recognized.
|
// the list if the syntax of the first item is not recognized.
|
||||||
next = next.replace(/SOCKS5 /g, 'SOCKS ');
|
return next.replace(/SOCKS5 /g, 'SOCKS ');
|
||||||
|
|
||||||
return next;
|
|
||||||
}
|
}
|
||||||
} else if (matchResult.profileName) {
|
} else if (matchResult.profileName) {
|
||||||
next = OmegaPac.Profiles.nameAsKey(matchResult.profileName)
|
next = OmegaPac.Profiles.nameAsKey(matchResult.profileName)
|
||||||
|
@ -199,10 +199,22 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
@_proxyScriptDisabled = true
|
@_proxyScriptDisabled = true
|
||||||
else
|
else
|
||||||
@_proxyScriptState = state
|
@_proxyScriptState = state
|
||||||
@_initWebextProxyScript().then => @_proxyScriptStateChanged()
|
Promise.all([
|
||||||
# Proxy authentication is not covered in WebExtensions standard now.
|
browser.runtime.getBrowserInfo(),
|
||||||
# MOZ: Mozilla has a bug tracked to implemented it in PAC return value.
|
@_initWebextProxyScript(),
|
||||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1319641
|
]).then ([info]) =>
|
||||||
|
if info.vendor == 'Mozilla' and info.buildID < '20170918220054'
|
||||||
|
# MOZ: Legacy proxy support expects PAC-like string return type.
|
||||||
|
# TODO(catus): Remove support for string return type.
|
||||||
|
@log.error(
|
||||||
|
'WARNING: Your browser is outdated! SOCKS5 DNS/Auth unsupported!')
|
||||||
|
@log.error('Please update your browser ASAP!')
|
||||||
|
@log.error("useLegacyStringReturn=true for Build: #{info.buildID}.")
|
||||||
|
@_proxyScriptState.useLegacyStringReturn = true
|
||||||
|
@_proxyScriptStateChanged()
|
||||||
|
@_proxyAuth ?= new ProxyAuth(this)
|
||||||
|
@_proxyAuth.listen()
|
||||||
|
@_proxyAuth.setProxies(@_watchingProfiles)
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
|
|
||||||
_proxyScriptInitialized: false
|
_proxyScriptInitialized: false
|
||||||
@ -210,11 +222,22 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
_initWebextProxyScript: ->
|
_initWebextProxyScript: ->
|
||||||
if not @_proxyScriptInitialized
|
if not @_proxyScriptInitialized
|
||||||
browser.proxy.onProxyError.addListener (err) =>
|
browser.proxy.onProxyError.addListener (err) =>
|
||||||
if err and err.message.indexOf('Invalid Proxy Rule: DIRECT') >= 0
|
if err?.message?
|
||||||
# DIRECT cannot be parsed in Mozilla earlier due to a bug. Even though
|
if err.message.indexOf('Invalid Proxy Rule: DIRECT') >= 0
|
||||||
# it throws, it actually falls back to direct connection so it works.
|
# DIRECT cannot be parsed in Mozilla earlier due to a bug. Even
|
||||||
|
# though it throws, it actually falls back to direct connection
|
||||||
|
# so it works.
|
||||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1355198
|
# https://bugzilla.mozilla.org/show_bug.cgi?id=1355198
|
||||||
return
|
return
|
||||||
|
if err.message.indexOf('Return type must be a string') >= 0
|
||||||
|
# MOZ: Legacy proxy support expects PAC-like string return type.
|
||||||
|
# TODO(catus): Remove support for string return type.
|
||||||
|
@log.error(
|
||||||
|
'WARNING: Your browser is outdated! Remote DNS is unsupported!')
|
||||||
|
@log.error('Please update your browser ASAP!')
|
||||||
|
@_proxyScriptState.useLegacyStringReturn = true
|
||||||
|
@_proxyScriptStateChanged()
|
||||||
|
return
|
||||||
@log.error(err)
|
@log.error(err)
|
||||||
browser.runtime.onMessage.addListener (message) =>
|
browser.runtime.onMessage.addListener (message) =>
|
||||||
return unless message.event == 'proxyScriptLog'
|
return unless message.event == 'proxyScriptLog'
|
||||||
|
@ -38,7 +38,12 @@ angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal,
|
|||||||
|
|
||||||
$scope.proxyEditors = {}
|
$scope.proxyEditors = {}
|
||||||
|
|
||||||
$scope.authSupported = {"http": true, "https": true}
|
socks5AuthSupported = (browser?.proxy?.register?)
|
||||||
|
$scope.authSupported = {
|
||||||
|
"http": true,
|
||||||
|
"https": true,
|
||||||
|
"socks5": socks5AuthSupported,
|
||||||
|
}
|
||||||
$scope.isProxyAuthActive = (scheme) ->
|
$scope.isProxyAuthActive = (scheme) ->
|
||||||
return $scope.profile.auth?[proxyProperties[scheme]]?
|
return $scope.profile.auth?[proxyProperties[scheme]]?
|
||||||
$scope.editProxyAuth = (scheme) ->
|
$scope.editProxyAuth = (scheme) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user