fix http proxies not being supported
This commit is contained in:
73
ext/bg.js
73
ext/bg.js
@@ -459,6 +459,26 @@ function attach_ws_events(ws){
|
|||||||
|
|
||||||
if(status){
|
if(status){
|
||||||
|
|
||||||
|
if(
|
||||||
|
msg.proxy.type == "http" ||
|
||||||
|
msg.proxy.type == "https"
|
||||||
|
){
|
||||||
|
|
||||||
|
if(typeof msg.proxy.proxyDNS == "boolean"){
|
||||||
|
|
||||||
|
delete msg.proxy.proxyDNS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof msg.proxy.port == "string"){
|
||||||
|
|
||||||
|
msg.proxy.port = parseInt(msg.proxy.port);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(msg.proxy);
|
||||||
|
|
||||||
proxy_map[msg.id] = msg.proxy;
|
proxy_map[msg.id] = msg.proxy;
|
||||||
send(ws, seqid, {status: true});
|
send(ws, seqid, {status: true});
|
||||||
return;
|
return;
|
||||||
@@ -731,6 +751,44 @@ browser.proxy.onRequest.addListener(function(request){
|
|||||||
urls: ["<all_urls>"]
|
urls: ["<all_urls>"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Automatically handle and detect all Proxy Authentication challenges
|
||||||
|
browser.webRequest.onAuthRequired.addListener(
|
||||||
|
function(details){
|
||||||
|
|
||||||
|
// Only intercept proxy auth requests, ignore normal website auth
|
||||||
|
if(!details.isProxy){
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const proxy_config = proxy_map[details.cookieStoreId];
|
||||||
|
|
||||||
|
// Check if the assigned proxy configuration for this container includes credentials
|
||||||
|
if(
|
||||||
|
proxy_config &&
|
||||||
|
(
|
||||||
|
proxy_config.type == "http" ||
|
||||||
|
proxy_config.type == "https"
|
||||||
|
) &&
|
||||||
|
proxy_config.username &&
|
||||||
|
proxy_config.password
|
||||||
|
){
|
||||||
|
|
||||||
|
return {
|
||||||
|
authCredentials: {
|
||||||
|
username: proxy_config.username,
|
||||||
|
password: proxy_config.password
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the proxy requires auth and we have no credentials, silently cancel
|
||||||
|
// to prevent hanging the browser with auth popup dialogs.
|
||||||
|
return { cancel: true };
|
||||||
|
},
|
||||||
|
{ urls: ["<all_urls>"] },
|
||||||
|
["blocking"]
|
||||||
|
);
|
||||||
|
|
||||||
browser.tabs.onUpdated.addListener(function(tabid, event, tab){
|
browser.tabs.onUpdated.addListener(function(tabid, event, tab){
|
||||||
|
|
||||||
if(global_ws === null){ return; }
|
if(global_ws === null){ return; }
|
||||||
@@ -768,6 +826,21 @@ browser.webRequest.onHeadersReceived.addListener(
|
|||||||
// send error on 4xx code
|
// send error on 4xx code
|
||||||
if(page.statusCode >= 400){
|
if(page.statusCode >= 400){
|
||||||
|
|
||||||
|
const proxy_config = proxy_map[details.cookieStoreId];
|
||||||
|
|
||||||
|
if(
|
||||||
|
proxy_config &&
|
||||||
|
(
|
||||||
|
proxy_config.type == "http" ||
|
||||||
|
proxy_config.type == "https"
|
||||||
|
) &&
|
||||||
|
page.statusCode === 407
|
||||||
|
){
|
||||||
|
|
||||||
|
// ignore http proxy auth error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
send_event(
|
send_event(
|
||||||
global_ws,
|
global_ws,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user