Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Tor Browser
Commits
be025b30
Verified
Commit
be025b30
authored
Dec 21, 2023
by
Pier Angelo Vendrame
Browse files
Options
Downloads
Patches
Plain Diff
fixup! Bug 40597: Implement TorSettings module
Convert TorSettings to an ES class.
parent
0d07d3a6
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!898
Bug 42252: Add further support for TorController in firefox-android
,
!877
Bug 42343: Read built-in bridges from pt_config.json instead of preferences.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit/modules/TorSettings.sys.mjs
+23
-21
23 additions, 21 deletions
toolkit/modules/TorSettings.sys.mjs
with
23 additions
and
21 deletions
toolkit/modules/TorSettings.sys.mjs
+
23
−
21
View file @
be025b30
...
...
@@ -215,13 +215,13 @@ const arrayShuffle = function (array) {
/* TorSettings module */
export
const
TorSettings
=
{
class
TorSettings
Impl
{
/**
* The underlying settings values.
*
* @type {object}
*/
_settings
:
{
_settings
=
{
quickstart
:
{
enabled
:
false
,
},
...
...
@@ -243,21 +243,21 @@ export const TorSettings = {
enabled
:
false
,
allowed_ports
:
[],
},
}
,
}
;
/**
* The current number of freezes applied to the notifications.
*
* @type {integer}
*/
_freezeNotificationsCount
:
0
,
_freezeNotificationsCount
=
0
;
/**
* The queue for settings that have changed. To be broadcast in the
* notification when not frozen.
*
* @type {Set<string>}
*/
_notificationQueue
:
new
Set
()
,
_notificationQueue
=
new
Set
()
;
/**
* Send a notification if we have any queued and we are not frozen.
*/
...
...
@@ -270,7 +270,7 @@ export const TorSettings = {
TorSettingsTopics
.
SettingsChanged
);
this
.
_notificationQueue
.
clear
();
}
,
}
/**
* Pause notifications for changes in setting values. This is useful if you
* need to make batch changes to settings.
...
...
@@ -282,7 +282,7 @@ export const TorSettings = {
*/
freezeNotifications
()
{
this
.
_freezeNotificationsCount
++
;
}
,
}
/**
* Release the hold on notifications so they may be sent out.
*
...
...
@@ -292,7 +292,7 @@ export const TorSettings = {
thawNotifications
()
{
this
.
_freezeNotificationsCount
--
;
this
.
_tryNotification
();
}
,
}
/**
* @typedef {object} TorSettingProperty
*
...
...
@@ -367,14 +367,14 @@ export const TorSettings = {
writable
:
false
,
value
:
group
,
});
}
,
}
/**
* Regular expression for a decimal non-negative integer.
*
* @type {RegExp}
*/
_portRegex
:
/^
[
0-9
]
+$/
,
_portRegex
=
/^
[
0-9
]
+$/
;
/**
* Parse a string as a port number.
*
...
...
@@ -403,7 +403,7 @@ export const TorSettings = {
return
null
;
}
return
val
;
}
,
}
/**
* Test whether two arrays have equal members and order.
*
...
...
@@ -417,7 +417,7 @@ export const TorSettings = {
return
false
;
}
return
val1
.
every
((
v
,
i
)
=>
v
===
val2
[
i
]);
}
,
}
/* load or init our settings, and register observers */
async
init
()
{
...
...
@@ -574,7 +574,7 @@ export const TorSettings = {
Services
.
obs
.
addObserver
(
this
,
lazy
.
TorProviderTopics
.
ProcessIsReady
);
}
}
,
}
/* wait for relevant life-cycle events to apply saved settings */
async
observe
(
subject
,
topic
,
data
)
{
...
...
@@ -589,7 +589,7 @@ export const TorSettings = {
await
this
.
handleProcessReady
();
break
;
}
}
,
}
// once the tor daemon is ready, we need to apply our settings
async
handleProcessReady
()
{
...
...
@@ -597,7 +597,7 @@ export const TorSettings = {
await
this
.
applySettings
();
lazy
.
logger
.
info
(
"
Ready
"
);
Services
.
obs
.
notifyObservers
(
null
,
TorSettingsTopics
.
Ready
);
}
,
}
// load our settings from prefs
loadFromPrefs
()
{
...
...
@@ -671,7 +671,7 @@ export const TorSettings = {
""
);
}
}
,
}
// save our settings to prefs
saveToPrefs
()
{
...
...
@@ -758,7 +758,7 @@ export const TorSettings = {
Services
.
prefs
.
setBoolPref
(
TorSettingsPrefs
.
enabled
,
true
);
return
this
;
}
,
}
// push our settings down to the tor daemon
async
applySettings
()
{
...
...
@@ -822,7 +822,7 @@ export const TorSettings = {
await
provider
.
writeSettings
(
settingsMap
);
return
this
;
}
,
}
// set all of our settings at once from a settings object
setSettings
(
settings
)
{
...
...
@@ -881,11 +881,13 @@ export const TorSettings = {
}
lazy
.
logger
.
debug
(
"
setSettings result
"
,
this
.
_settings
);
}
,
}
// get a copy of all our settings
getSettings
()
{
lazy
.
logger
.
debug
(
"
getSettings()
"
);
return
structuredClone
(
this
.
_settings
);
},
};
}
}
export
const
TorSettings
=
new
TorSettingsImpl
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment