@@ -30,7 +30,7 @@ export const handleProxyRequest = async (details: browser.proxy._OnRequestDetail
30
30
const hostProxiesDetailsParsed : Record < string , ProxyDetails > = JSON . parse ( hostProxiesDetails ) ;
31
31
32
32
const currentHost = getCurrentHost ( details ) ;
33
- const { hasSubdomain, domain, subDomain, isMullvadNet } = checkDomain ( currentHost ) ;
33
+ const { hasSubdomain, domain, subDomain } = checkDomain ( currentHost ) ;
34
34
const currentDomain = hasSubdomain ? subDomain : domain ;
35
35
36
36
const isDomainExcluded = excludedHostsParsed . includes ( currentDomain ) ;
@@ -50,13 +50,7 @@ export const handleProxyRequest = async (details: browser.proxy._OnRequestDetail
50
50
51
51
// 3. When the request if a conncheck/DNS check originating from the extension,
52
52
// we want to use the same proxy as the active tab, to get a consistent conncheck result
53
- const isExtensionRequest = details . documentUrl ?. startsWith ( 'moz-extension://' ) ;
54
- const isConnCheck = isMullvadNet && details . url ?. endsWith ( 'am.i.mullvad.net/json' ) ;
55
- const isDNSCheck = isMullvadNet && details . url ?. endsWith ( 'dnsleak.am.i.mullvad.net/' ) ;
56
-
57
- const isExtConnCheck = isExtensionRequest && ( isConnCheck || isDNSCheck ) ;
58
-
59
- if ( isExtConnCheck ) {
53
+ if ( isExtConnCheck ( details ) ) {
60
54
return getProxyForExtensionConnectionCheck (
61
55
isGlobalProxyEnabled ,
62
56
globalConfigParsed ,
@@ -115,6 +109,17 @@ const getCurrentHost = (details: RequestDetails) => {
115
109
return new URL ( details . url ) . hostname ;
116
110
} ;
117
111
112
+ const isExtConnCheck = ( details : RequestDetails ) : boolean => {
113
+ const isExtensionRequest = Boolean ( details . documentUrl ?. startsWith ( 'moz-extension://' ) ) ;
114
+ const isConnCheck =
115
+ details . url === 'https://ipv4.am.i.mullvad.net/json' ||
116
+ details . url === 'https://ipv6.am.i.mullvad.net/json' ;
117
+ const isDNSCheck =
118
+ checkDomain ( details . url ) . domain === 'mullvad.net' && details . url . endsWith ( 'am.i.mullvad.net/' ) ;
119
+
120
+ return isExtensionRequest && ( isConnCheck || isDNSCheck ) ;
121
+ } ;
122
+
118
123
export const isLocalOrReservedIP = ( hostname : string ) => {
119
124
if ( hostname . includes ( 'localhost' ) ) return true ;
120
125
if ( ! ipaddr . isValid ( hostname ) ) return false ;
0 commit comments