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

Commit

Permalink
Remove tor test (muon will automatically bring up tor process)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Mar 24, 2018
1 parent a6967c1 commit e61cee6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 96 deletions.
7 changes: 0 additions & 7 deletions app/browser/reducers/aboutNewTabReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ const aboutNewTabReducer = (state, action) => {
case appConstants.APP_TOP_SITE_DATA_AVAILABLE:
state = aboutNewTabState.setSites(state, action.topSites)
break
case appConstants.APP_TOR_AVAILABLE:
state = aboutNewTabState.mergeDetails(state, {
newTabPageDetail: {
torAvailable: action.value
}
})
break
case appConstants.APP_CHANGE_NEW_TAB_DETAIL:
state = aboutNewTabState.mergeDetails(state, action)
if (action.refresh) {
Expand Down
13 changes: 5 additions & 8 deletions app/common/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,11 @@ module.exports.newPrivateTabMenuItem = () => {
// Check if Tor is available
const useTor = getSetting(settings.USE_TOR_PRIVATE_TABS)
if (useTor) {
const cb = (success) => {
ensureAtLeastOneWindow({
url: 'about:newtab',
isPrivate: true,
isTor: success
})
}
appActions.checkTorAvailable(cb)
ensureAtLeastOneWindow({
url: 'about:newtab',
isPrivate: true,
isTor: true
})
} else {
ensureAtLeastOneWindow({
url: 'about:newtab',
Expand Down
55 changes: 1 addition & 54 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const downloadStates = require('../js/constants/downloadStates')
const urlParse = require('./common/urlParse')
const getSetting = require('../js/settings').getSetting
const appUrlUtil = require('../js/lib/appUrlUtil')
const {request} = require('../js/lib/request')
const siteSettings = require('../js/state/siteSettings')
const settings = require('../js/constants/settings')
const userPrefs = require('../js/state/userPrefs')
Expand All @@ -42,7 +41,7 @@ const beforeSendHeadersFilteringFns = []
const beforeRequestFilteringFns = []
const beforeRedirectFilteringFns = []
const headersReceivedFilteringFns = []
let partitionsToInitialize = ['default', 'tor-test']
let partitionsToInitialize = ['default']
let initializedPartitions = {}

const transparent1pxGif = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
Expand Down Expand Up @@ -638,47 +637,6 @@ function registerForMagnetHandler (session) {
}
}

/**
* Checks that a Tor proxy is available on socks5 port 9050
* @param {Function(boolean)} cb - callback with result of tor availability
*/
module.exports.checkTorAvailable = (cb) => {
const ses = registeredSessions['tor-test']
if (!ses) {
initPartition('tor-test')
module.exports.checkTorAvailable(cb)
return
}

const proxyConfig = {
proxyRules: 'socks5://127.0.0.1:9050,direct://'
}
ses.setProxy(proxyConfig, () => {
request('https://check.torproject.org/?TorButton=true', (err, response, body) => {
let success = null
if (err) {
console.log('Could not check Tor status', err)
} else if (body && body.includes('id="TorCheckResult" target="success"')) {
// success
console.log('Tor is running!')
success = true
} else if (body && body.includes('id="TorCheckResult" target="failure"')) {
// we are not using Tor
console.log('Tor is not running.')
success = false
} else {
// unknown error
console.log('Bad response from check.torproject.org. HTTP status:',
response.statusCode)
}
appActions.torAvailable(success)
if (cb) {
cb(success)
}
}, ses)
})
}

module.exports.setTorNewIdentity = (url, tabId) => {
const ses = session.fromPartition('persist:tor')
if (!ses || !url) {
Expand All @@ -698,7 +656,6 @@ function initSession (ses, partition) {

const initPartition = (partition) => {
const isTorPartition = partition === 'persist:tor'
const isTorTestPartition = partition === 'tor-test'
// Partitions can only be initialized once the app is ready
if (!app.isReady()) {
partitionsToInitialize.push(partition)
Expand All @@ -709,16 +666,6 @@ const initPartition = (partition) => {
}
initializedPartitions[partition] = true

if (isTorTestPartition) {
// This partition is only used to check for Tor proxy availability
let ses = session.fromPartition(partition, {
parent_partition: '',
cache: false
})
registeredSessions[partition] = ses
return
}

let fns = [initSession,
userPrefs.init,
hostContentSettings.init,
Expand Down
1 change: 0 additions & 1 deletion docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ AppStore
sites: [string], // list of sites to be used on gridLayout. Defaults to 6 Brave-related sites; see data/newTabData.js => topSites
updatedStamp: number, // timestamp for when the data was last updated
torEnabled: boolean, // whether Tor private tabs is enabled
torAvailable: boolean, // whether a Tor process is available
},
preferences: {
recoverySucceeded: (boolean|undefined),
Expand Down
33 changes: 15 additions & 18 deletions js/about/newprivatetab.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const aboutActions = require('./aboutActions')
require('../../less/about/newtab.less')

const useAlternativePrivateSearchEngineDataKeys = ['newTabDetail', 'useAlternativePrivateSearchEngine']
const torAvailable = ['newTabDetail', 'torAvailable']
const torEnabled = ['newTabDetail', 'torEnabled']

class NewPrivateTab extends React.Component {
Expand Down Expand Up @@ -77,24 +76,22 @@ class NewPrivateTab extends React.Component {
</div>
}
{
this.props.newTabData.getIn(torAvailable)
? <div className={css(styles.privateSearch)}>
<div className={css(styles.privateSearch__setting)}>
<SettingCheckbox
large
switchClassName={css(styles.privateSearch__switch)}
rightLabelClassName={css(styles.sectionTitle)}
checked={Boolean(this.props.newTabData.getIn(torEnabled))}
onChange={this.onChangeTor.bind(this)}
/>
<h2 onClick={this.onClickTorTitle.bind(this)} className={css(styles.privateSearch__title)}>
<span className={css(styles.text_sectionTitle)} data-l10n-id='privateTabTorTitle' />
</h2>
<img className={css(styles.privateSearch__ddgImage)} src={torIcon} alt='Tor logo' />
</div>
<p className={css(styles.text, styles.text_privateSearch)} data-l10n-id='privateTabTorText1' />
<div className={css(styles.privateSearch)}>
<div className={css(styles.privateSearch__setting)}>
<SettingCheckbox
large
switchClassName={css(styles.privateSearch__switch)}
rightLabelClassName={css(styles.sectionTitle)}
checked={Boolean(this.props.newTabData.getIn(torEnabled))}
onChange={this.onChangeTor.bind(this)}
/>
<h2 onClick={this.onClickTorTitle.bind(this)} className={css(styles.privateSearch__title)}>
<span className={css(styles.text_sectionTitle)} data-l10n-id='privateTabTorTitle' />
</h2>
<img className={css(styles.privateSearch__ddgImage)} src={torIcon} alt='Tor logo' />
</div>
: null
<p className={css(styles.text, styles.text_privateSearch)} data-l10n-id='privateTabTorText1' />
</div>
}
</div>
</div>
Expand Down
7 changes: 0 additions & 7 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1969,13 +1969,6 @@ const appActions = {
})
},

torAvailable: function (value) {
dispatch({
actionType: appConstants.APP_TOR_AVAILABLE,
value
})
},

setTorNewIdentity: function () {
dispatch({
actionType: appConstants.APP_SET_TOR_NEW_IDENTITY
Expand Down
1 change: 0 additions & 1 deletion js/constants/appConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ const appConstants = {
APP_ON_REFERRAL_ACTIVITY: _,
APP_ON_LEDGER_MEDIA_PUBLISHER: _,
APP_CHECK_TOR_AVAILABLE: _,
APP_TOR_AVAILABLE: _,
APP_SET_TOR_NEW_IDENTITY: _,
APP_RECREATE_TOR_TAB: _
}
Expand Down

0 comments on commit e61cee6

Please sign in to comment.