*/, "" /* aConnectionIsolationKey */, Ci.nsIProxyInfo.TRANSPARENT_PROXY_RESOLVES_HOST /* aFlags */, PR_UINT32_MAX /* aFailoverTimeout */, null /* failover proxy */ ) ); } #applyFilter = (channel, defaultProxyInfo, proxyFilter) => { const originAttributes = channel.loadInfo && channel.loadInfo.originAttributes; if ( this.#userContextToProxyConfiguration.has(originAttributes.userContextId) ) { const proxyInfo = this.#userContextToProxyConfiguration.get( originAttributes.userContextId ); if (proxyInfo.proxyType === lazy.ProxyTypes.Direct) { proxyFilter.onProxyFilterResult(null); return; } if (proxyInfo.proxyType === lazy.ProxyTypes.Manual) { const channelURI = channel.originalURI; for (const url of proxyInfo.noProxy ?? []) { if ( (url.startsWith(".") && channelURI.host.endsWith(url)) || (!url.startsWith(".") && channelURI.host === url) ) { proxyFilter.onProxyFilterResult(defaultProxyInfo); // If at least one element from noProxy matches the channel URL no need to check further. return; } } if (proxyInfo.httpProxy) { this.#addProxyFilter(proxyFilter, { host: proxyInfo.httpProxy, port: proxyInfo.httpProxyPort, type: "http", }); } if (proxyInfo.sslProxy) { this.#addProxyFilter(proxyFilter, { host: proxyInfo.sslProxy, port: proxyInfo.sslProxyPort, type: "https", }); } if (proxyInfo.socksProxy) { this.#addProxyFilter(proxyFilter, { host: proxyInfo.socksProxy, port: proxyInfo.socksProxyPort, type: proxyInfo.socksVersion === 5 ? "socks" : `socks${proxyInfo.socksVersion}`, }); } return; } } proxyFilter.onProxyFilterResult(defaultProxyInfo); }; #registerProxyFilter() { if (!this.#proxyFilterRegistered) { this.#proxyFilterRegistered = true; this.#channelProxyFilter = { QueryInterface: nsIProtocolProxyChannelFilter, applyFilter: this.#applyFilter, }; lazy.protocolProxyService.registerChannelFilter( this.#channelProxyFilter, 0 /* set position `0` to override global filters */ ); } } #unregisterProxyFilter() { if ( this.#proxyFilterRegistered && this.#userContextToProxyConfiguration.size === 0 ) { this.#proxyFilterRegistered = false; lazy.protocolProxyService.unregisterChannelFilter( this.#channelProxyFilter ); this.#channelProxyFilter = null; } } } PK