Skip to content

Commit

Permalink
v3.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
z0ccc committed Oct 28, 2022
1 parent 64ff5e5 commit f0d6996
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 55 deletions.
4 changes: 2 additions & 2 deletions modules/ext/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ext",
"version": "3.4.3",
"version": "3.4.7",
"private": true,
"dependencies": {
"@babel/plugin-proposal-export-default-from": "~7.8.3",
Expand Down Expand Up @@ -134,7 +134,7 @@
"web-ext": "~4.0.0",
"webpack-dev-server": "^3.11.0"
},
"uBlockVersion": "ws-v1.42.4",
"uBlockVersion": "ws-v1.43.0",
"main": "index.js",
"license": "MIT"
}
4 changes: 2 additions & 2 deletions modules/ext/public/manifest/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"manifest_version": 2,
"name": "Windscribe - Free Proxy and Ad Blocker",
"short_name": "Windscribe",
"version": "3.4.3",
"version": "3.4.7",
"description": "Windscribe helps you mask your physical location, circumvent censorship, and block ads and trackers on websites you use every day",
"content_security_policy": "script-src 'self'; object-src 'self';",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self';",
"default_locale": "en",
"browser_action": {
"default_popup": "popup.html",
Expand Down
20 changes: 16 additions & 4 deletions modules/ext/src/plugins/proxy/pac.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// TODO: this file is getting minified in the build and breaking the pacfile
// import shouldNotProxy from 'plugins/proxy/shouldNotProxy'
import { stringify } from 'utils/createCruiseControlList'
import api from 'api'
import { store } from 'state'

// get array of hostnames if exists (used for fallbacks)
const getParsedHostnamesString = hostnames => {
const getParsedHostnamesString = (hostnames, proxyPort) => {
if (hostnames?.length > 0) {
return hostnames.reduce((acc, hostname) => {
//convert each into proxy list format
acc += `HTTPS ${hostname}:443;`
acc += `HTTPS ${hostname}:${proxyPort};`
return acc
}, '')
} else {
Expand All @@ -21,6 +23,9 @@ const createFindProxyForURLFunction = ({
cruiseControlList,
whitelist = [],
}) => {
const { workingApi } = api.getConfig()
const proxyPort = store.getState().proxyPort

const pac = `
function FindProxyForURL (url, host) {
function shouldNotProxy(url, host, userWhitelist) {
Expand All @@ -30,7 +35,14 @@ const createFindProxyForURLFunction = ({
'*://api.windscribe.com/*',
'*://assets.windscribe.com/*',
'*://*.staticnetcontent.com/*',
'*://*.totallyacdn.com/*',
'*://api.totallyacdn.com/*',
'*://assets.totallyacdn.com/*',
${
workingApi !== '.windscribe.com'
? `'*://api${workingApi}/*',
'*://assets${workingApi}/*',`
: ''
}
'https://windscribe.com/installed/*',
].concat(userWhitelist)
Expand All @@ -48,7 +60,7 @@ const createFindProxyForURLFunction = ({
return 'DIRECT'
}
${cruiseControlList ? stringify(cruiseControlList) : ''}
return '${getParsedHostnamesString(hostnames)}'
return '${getParsedHostnamesString(hostnames, proxyPort)}'
}
`
return pac
Expand Down
12 changes: 11 additions & 1 deletion modules/ext/src/plugins/proxy/shouldNotProxy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import api from 'api'

// These functions exist in the pac sandbox, but not in the typical browser env

export const isPlainHostName = host => host.indexOf('.') === -1
Expand Down Expand Up @@ -60,17 +62,25 @@ export function shExpMatch(url, pattern) {
*/

// if this returns true then proxy should go DIRECT

export default function shouldNotProxy(url, host, userWhitelist) {
const { workingApi } = api.getConfig()

const lanIps = /(^(127|10)\.\d{1,3}\.\d{1,3}\.\d{1,3}$)|(^192\.168\.\d{1,3}\.\d{1,3}$)|(^172\.1[6-9]\.\d{1,3}\.\d{1,3}$)|(^172\.2[0-9]\.\d{1,3}\.\d{1,3}$)|(^172\.3[0-1]\.\d{1,3}\.\d{1,3}$)/

const whitelist = [
'*://api.windscribe.com/*',
'*://assets.windscribe.com/*',
'*://*.staticnetcontent.com/*',
'*://*.totallyacdn.com/*',
'*://api.totallyacdn.com/*',
'*://assets.totallyacdn.com/*',
'https://windscribe.com/installed/*',
].concat(userWhitelist)

if (workingApi !== '.windscribe.com') {
whitelist.push(`*://api${workingApi}/*`, `*://assets${workingApi}/*`)
}

return [
isPlainHostName(host),
// if it is NOT an allowed protocol then go direct
Expand Down
8 changes: 1 addition & 7 deletions modules/ext/src/plugins/session/getSessionAndCheckStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,7 @@ export default actions => [
message: `get latest session info failed: ${err.message}`,
})
// if session if invalid, logout
// 501 & 502 are validation errors
if (
err.code === SESSION_ERRORS.SESSION_INVALID ||
err.code === SESSION_ERRORS.NO_AUTH_HASH ||
err.code === 501 ||
err.code === 502
) {
if (err.code === SESSION_ERRORS.SESSION_INVALID) {
// this error will appear when you reach login page
dispatch(
actions.session.assign({
Expand Down
2 changes: 1 addition & 1 deletion modules/ext/src/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { store, actions } from 'state'

export default async () => {
window.ipAddress = await checkIp()
window.ublockNetWhitelist = µBlock.netWhitelist
// window.ublockNetWhitelist = µBlock.netWhitelist
window.checkIp = checkIp
window.constants = constants
window.sleep = sleep
Expand Down
2 changes: 1 addition & 1 deletion modules/ext/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const AUTH_RESET_MIN_INTERVAL =
export const RENDER_TIMEOUT = process.env.WEB_EXT_RENDER_TIMEOUT || 5000

export const PROXY_PORT =
process.env.WEB_EXT_PROXY_PORT || IS_FIREFOX ? '80' : '443'
process.env.WEB_EXT_PROXY_PORT || IS_FIREFOX ? '9443' : '443'

export const API_CALL_MIN_INTERVAL =
process.env.WEB_EXT_API_CALL_MIN_INTERVAL || 1000
10 changes: 7 additions & 3 deletions modules/ext/src/utils/createCruiseControlList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { flatten } from 'lodash'
import pickHosts from './pickHosts'
import { store } from 'state'

export default ({ serverlist, userPremiumStatus, cruiseControlDomains }) => {
// we only care about servers we can actually access
Expand All @@ -25,14 +26,17 @@ export default ({ serverlist, userPremiumStatus, cruiseControlDomains }) => {
}))
}

export const stringify = cruiseControlList =>
cruiseControlList
export const stringify = cruiseControlList => {
const proxyPort = store.getState().proxyPort

return cruiseControlList
.map(
loc =>
`if ([${flatten(
loc.domains.map(domain => [`'*://${domain}/*'`, `'*.${domain}/*'`]),
)}].some(d => shExpMatch(url, d))) {
return '${loc.hosts.map(x => `HTTPS ${x}:443`).join('; ')}'
return '${loc.hosts.map(x => `HTTPS ${x}:${proxyPort}`).join('; ')}'
}`,
)
.join('\n')
}
21 changes: 13 additions & 8 deletions modules/ext/src/utils/public-ip.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import api from 'api'

export default async () => {
const controller = new AbortController()
setTimeout(() => controller.abort(), 3000)
const { workingApi } = api.getConfig()
if (workingApi) {
const controller = new AbortController()
setTimeout(() => controller.abort(), 3000)

const response = await fetch('https://checkipv4.windscribe.com', {
signal: controller.signal,
})
.then(r => r.text())
.catch(() => '---.---.---.---')
return response
return await fetch(`https://checkip${workingApi}`, {
signal: controller.signal,
})
.then(r => r.text())
.catch(() => '---.---.---.---')
}
return '---.---.---.---'
}
1 change: 1 addition & 0 deletions modules/ext/src/views/Main/ProxyControls/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default memo(() => {
css={css`
align-items: center;
justify-content: start;
width: 150px;
`}
>
<ConnectionStatus status={status} online={online} />
Expand Down
1 change: 1 addition & 0 deletions modules/ext/src/views/Main/ProxyControls/IPAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default memo(({ showIpCopiedAlert, setIpCopiedAlert }) => {
text-overflow: ellipsis;
cursor: ${status === 'error' ? 'default' : 'pointer'};
${isIpBlurred && `text-shadow: 0px 0px 6px rgba(255,255,255,0.5);`}
width: 140px;
`}
fontSize={0}
notranslate="true"
Expand Down
2 changes: 1 addition & 1 deletion modules/ext/src/views/PreferencesConnection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default () => {
<DropDown
type={'proxyPort'}
current={proxyPort}
items={['443', '80']}
items={['443', '9443']}
ACTIVITY={ACTIVITY}
/>
</SettingItem>
Expand Down
2 changes: 1 addition & 1 deletion modules/ext/src/views/PreferencesPrivacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default () => {
subHeading={
'Limits WebRTC requests to prevent leaks. This may break some applications.'
}
path={'features/timezone-spoofing'}
path={'features/webrtc-slayer'}
Icon={WebRTCIcon}
>
<ToggleSwitch
Expand Down
2 changes: 2 additions & 0 deletions modules/ws-api-client/src/api/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Dispatch, SessionType } from './commonTypes'

export interface Config {
workingApi?: string | null
apiUrl?: string
assetsUrl?: string
backupApiUrl?: string
Expand All @@ -14,6 +15,7 @@ export interface Config {
}

export let globalConfig: Config = {
workingApi: null,
apiUrl: process.env.API_URL,
assetsUrl: process.env.ASSETS_URL,
backupApiUrl: process.env.BACKUP_API_URL,
Expand Down
17 changes: 17 additions & 0 deletions modules/ws-api-client/src/api/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ const request: ApiRequest = async ({
assets,
actionCreators: {},
})

if (!response) {
throw {
code: 0,
message: 'Error fetching API',
debug: {
response: {},
debugOpts: {},
endpoint: '',
url: '',
},
data:
'{"errorCode":0, "errorMessage":"Error fetching API", "logStatus":null}',
}
}

/* check for errors in the response body */
const data = await parseResponse({
response,
Expand All @@ -118,6 +134,7 @@ const request: ApiRequest = async ({
url: global.url,
},
})

if (successfulReduxAction) {
dispatcher({ actionCreator: successfulReduxAction, data })
}
Expand Down
Loading

0 comments on commit f0d6996

Please sign in to comment.