Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
disable webrtc in tor mode
Browse files Browse the repository at this point in the history
fix #13397
fix lint
add note to shields panel about breakage in tor mode
  • Loading branch information
diracdeltas committed Mar 27, 2018
1 parent 7ddf69e commit 8c46b17
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
5 changes: 4 additions & 1 deletion app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Immutable = require('immutable')
const dragTypes = require('../../../js/constants/dragTypes')
const tabActionConsts = require('../../common/constants/tabAction')
const flash = require('../../../js/flash')
const {frameOptsFromFrame} = require('../../../js/state/frameStateUtil')
const {frameOptsFromFrame, isTor} = require('../../../js/state/frameStateUtil')
const {isSourceAboutUrl, isTargetAboutUrl, isNavigatableAboutPage} = require('../../../js/lib/appUrlUtil')
const {shouldDebugTabEvents} = require('../../cmdLine')

Expand All @@ -35,6 +35,9 @@ const getWebRTCPolicy = (state, tabId) => {
if (tabValue == null) {
return WEBRTC_DEFAULT
}
if (isTor(tabValue)) {
return WEBRTC_DISABLE_NON_PROXY
}
const allSiteSettings = siteSettingsState.getAllSiteSettings(state, tabValue.get('incognito') === true)
const tabSiteSettings =
siteSettings.getSiteSettingsForURL(allSiteSettings, tabValue.get('url'))
Expand Down
5 changes: 3 additions & 2 deletions app/extensions/brave/locales/en-US/bravery.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ blockAllCookies=Block all cookies
blockAllFingerprinting=Block all fingerprinting
blockPopups=Block Popups
cookieControl=Cookie Control
editBraveryGlobalSettings=Edit default shield settings…
editBraveryGlobalSettings=Edit default shield settings…
braveryTorWarning=For your protection, some sites will not work fully in Tor mode.
fingerprintingBlocked={[plural(blockedFingerprintCount)]}
fingerprintingBlocked[one]=Fingerprinting Method Blocked
fingerprintingBlocked[other]=Fingerprinting Methods Blocked
Expand All @@ -28,4 +29,4 @@ safeBrowsing=Block Phishing / Malware
scriptsBlockedNumber={[plural(blockedScriptCount)]}
scriptsBlockedNumber[one]=Script Blocked
scriptsBlockedNumber[other]=Scripts Blocked
showBraveAds=Show Brave Ads
showBraveAds=Show Brave Ads
11 changes: 11 additions & 0 deletions app/renderer/components/main/braveryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class BraveryPanel extends React.Component {
props.isBlockedScriptsShown = braveryPanelDetail.get('expandNoScript')
props.isBlockingFingerprinting = props.blockedFingerprinting.size > 0
props.isFpShown = braveryPanelDetail.get('expandFp')
props.isTor = frameStateUtil.isTor(activeFrame)

// used in other functions
props.lastCommittedURL = lastCommittedURL
Expand Down Expand Up @@ -623,6 +624,16 @@ class BraveryPanel extends React.Component {
</section>
: null
}
{
this.props.isTor
? <div className={css(
styles.braveryPanel__body__footer__edit,
this.props.isCompactBraveryPanel && styles.braveryPanel_compact__body__footer__edit
)}
data-l10n-id='braveryTorWarning'
/>
: null
}
<hr className={css(
styles.braveryPanel__body__hr,
this.props.isCompactBraveryPanel && styles.braveryPanel_compact__body__hr
Expand Down
4 changes: 0 additions & 4 deletions app/renderer/components/tabs/content/favIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ const {spinKeyframes, opacityIncreaseElementKeyframes} = require('../../styles/a

const defaultIconSvg = require('../../../../extensions/brave/img/tabs/default.svg')
const loadingIconSvg = require('../../../../extensions/brave/img/tabs/loading.svg')
const settings = require('../../../../../js/constants/settings')
const {getSetting} = require('../../../../../js/settings')
const appConfig = require('../../../../../js/constants/appConfig')
const domUtil = require('../../../lib/domUtil')

const isLocalFavicon = (favicon) => {
if (!favicon) {
Expand Down
5 changes: 3 additions & 2 deletions js/state/frameStateUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Immutable = require('immutable')

// Constants
const config = require('../constants/config')
const appConfig = require('../constants/appConfig')
const settings = require('../constants/settings')

// Actions
Expand Down Expand Up @@ -480,10 +481,10 @@ const isFirstFrameKeyInTabPage = (state, frameKey) => {
}

/**
* Check if frame is tor private tab
* Check if frame or tab object is associated with a tor private tab
*/
function isTor (frame) {
return !!(frame && frame.get('isPrivate') && getSetting(settings.USE_TOR_PRIVATE_TABS))
return !!(frame && frame.get('partition') === appConfig.tor.partition)
}

const getTabPageIndex = (state) => {
Expand Down
11 changes: 2 additions & 9 deletions test/unit/state/frameStateUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,8 @@ describe('frameStateUtil', function () {
})

describe('isTor', function () {
before(function () {
getSettingsValue = true
})
const frame1 = Immutable.Map({isPrivate: true})
const frame2 = Immutable.Map({isPrivate: false})
const frame1 = Immutable.Map({partition: 'persist:tor'})
const frame2 = Immutable.Map({partition: ''})
const frame3 = Immutable.Map({foobar: false})
it('null frame case', function () {
assert.equal(frameStateUtil.isTor(null), false)
Expand All @@ -512,9 +509,5 @@ describe('frameStateUtil', function () {
it('tor frame case', function () {
assert.equal(frameStateUtil.isTor(frame1), true)
})
it('tor disabled case', function () {
getSettingsValue = false
assert.equal(frameStateUtil.isTor(frame1), false)
})
})
})

0 comments on commit 8c46b17

Please sign in to comment.