better proxy handling
This commit is contained in:
+6
-1
@@ -55,8 +55,8 @@ export default class BackgroundMain {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Fix in @types/firefox-webext-browser
|
||||
async onRequest(requestDetails: Pick<_OnRequestDetails, 'cookieStoreId' | 'url' | 'tabId'>): Promise<DoNotProxy | ProxyInfo[]> {
|
||||
if (requestDetails.tabId > -1) {
|
||||
const tab = (await browser.tabs.get(requestDetails.tabId))
|
||||
|
||||
if (tab.cookieStoreId?.startsWith(containerIdentifier) === true) {
|
||||
@@ -65,6 +65,10 @@ export default class BackgroundMain {
|
||||
|
||||
const proxies = await this.store.getProxiesForContainer(cookieStoreId)
|
||||
|
||||
if (proxies === null) {
|
||||
return doNotProxy
|
||||
}
|
||||
|
||||
if (proxies.length > 0) {
|
||||
proxies.forEach(p => {
|
||||
if (p.type === ProxyType.Http || p.type === ProxyType.Https) {
|
||||
@@ -98,6 +102,7 @@ export default class BackgroundMain {
|
||||
return [emergencyBreak]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return doNotProxy
|
||||
}
|
||||
|
||||
@@ -119,13 +119,13 @@ export class Store {
|
||||
}
|
||||
}
|
||||
|
||||
async getProxiesForContainer(cookieStoreId: string): Promise<ProxySettings[]> {
|
||||
async getProxiesForContainer(cookieStoreId: string): Promise<ProxySettings[] | null> {
|
||||
const relations = await this.getRelations()
|
||||
|
||||
const proxyIds: string[] = relations[cookieStoreId] ?? []
|
||||
|
||||
if (proxyIds.length === 0) {
|
||||
return []
|
||||
return null
|
||||
}
|
||||
|
||||
const proxies = await this.getAllProxies()
|
||||
|
||||
Reference in New Issue
Block a user