Skip to content

Commit

Permalink
Block speculative requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihildt committed Nov 25, 2024
1 parent ad250ef commit eef2dab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/helpers/socksProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export const handleProxyRequest = async (details: browser.proxy._OnRequestDetail
const proxiedHosts = Object.keys(hostProxiesParsed);
const currentHost = getCurrentHost(details);

if (excludedHostsParsed.includes(currentHost) || isLocalOrReservedIP(currentHost)) {
// Since we can't identify speculative requests origin, we need to block them
// See: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy
if (details.type === 'speculative') {
return { cancel: true };
} else if (excludedHostsParsed.includes(currentHost) || isLocalOrReservedIP(currentHost)) {
return { type: 'direct' };
} else if (
proxiedHosts.includes(currentHost) &&
Expand Down

0 comments on commit eef2dab

Please sign in to comment.