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
0b146565
Verified
Commit
0b146565
authored
Jul 9, 2024
by
Pier Angelo Vendrame
Browse files
Options
Downloads
Patches
Plain Diff
fixup! Bug 40933: Add tor-launcher functionality
Fix some comments.
parent
2348214b
Branches
Branches containing commit
No related tags found
1 merge request
!1043
Bug 42616: Rebased alpha onto Firefox 128.0b1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
toolkit/components/tor-launcher/TorControlPort.sys.mjs
+15
-14
15 additions, 14 deletions
toolkit/components/tor-launcher/TorControlPort.sys.mjs
toolkit/components/tor-launcher/TorProvider.sys.mjs
+11
-8
11 additions, 8 deletions
toolkit/components/tor-launcher/TorProvider.sys.mjs
with
26 additions
and
22 deletions
toolkit/components/tor-launcher/TorControlPort.sys.mjs
+
15
−
14
View file @
0b146565
...
...
@@ -109,14 +109,15 @@ class AsyncSocket {
* Otherwise, the previous item of the queue will run it after it finishes.
*
* @param {string} str The string to write to the socket. The underlying
* implementation shoul
w
convert JS strings (UTF-16) into UTF-8 strings.
* implementation shoul
d
convert JS strings (UTF-16) into UTF-8 strings.
* See also write nsIOutputStream (the first argument is a string, not a
* wstring).
* @returns {Promise<number>} The number of written bytes
*/
async
write
(
str
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// asyncWait next write request
// Asynchronously wait for the stream to be writable (or closed) if we
// have any pending requests.
const
tryAsyncWait
=
()
=>
{
if
(
this
.
#outputQueue
.
length
)
{
this
.
#outputStream
.
asyncWait
(
...
...
@@ -135,16 +136,16 @@ class AsyncSocket {
try
{
const
bytesWritten
=
this
.
#outputStream
.
write
(
str
,
str
.
length
);
//
r
emove this callback object from queue as it is now completed
//
R
emove this callback object from queue
,
as it is now completed
.
this
.
#outputQueue
.
shift
();
//
request next wai
t if there is one
//
Queue the next reques
t if there is one
.
tryAsyncWait
();
//
f
inally resolve promise
//
F
inally
,
resolve
the
promise
.
resolve
(
bytesWritten
);
}
catch
(
err
)
{
//
r
eject promise on error
//
R
eject
the
promise on error
.
reject
(
err
);
}
},
...
...
@@ -280,7 +281,7 @@ class AsyncSocket {
/**
* @typedef {object} Bridge
* @property {string} transport The transport of the bridge, or vanilla if not
* specified
.
* specified
* @property {string} addr The IP address and port of the bridge
* @property {NodeFingerprint} id The fingerprint of the bridge
* @property {string} args Optional arguments passed to the bridge
...
...
@@ -288,7 +289,7 @@ class AsyncSocket {
/**
* @typedef {object} PTInfo The information about a pluggable transport
* @property {string[]} transports An array with all the transports supported by
* this configuration
.
* this configuration
* @property {string} type Either socks4, socks5 or exec
* @property {string} [ip] The IP address of the proxy (only for socks4 and
* socks5)
...
...
@@ -441,8 +442,8 @@ export class TorController {
* @returns {Promise<string>} The read message (without the final CRLF)
*/
async
#readMessage
()
{
//
w
hether we are searching for the end of a multi-line values
// See control-spec section 3.9
//
W
hether we are searching for the end of a multi-line values
.
// See control-spec section 3.9
.
let
handlingMultlineValue
=
false
;
let
endOfMessageFound
=
false
;
const
message
=
[];
...
...
@@ -466,8 +467,8 @@ export class TorController {
if
(
message
.
length
===
1
&&
line
.
match
(
/^
\d\d\d\+
.+
?
=$/
))
{
handlingMultlineValue
=
true
;
}
//
l
ook for end of message (notice the space character at end of the
// regex!)
//
L
ook for end of message (notice the space character at end of the
// regex!)
.
else
if
(
line
.
match
(
/^
\d\d\d
/
))
{
if
(
message
.
length
===
1
)
{
endOfMessageFound
=
true
;
...
...
@@ -662,7 +663,7 @@ export class TorController {
*
* @param {string} key The key to get value for
* @returns {Promise<string>} The string we received (only the value, without
* the key). We do not do any additional parsing on it
.
* the key). We do not do any additional parsing on it
*/
async
#getInfo
(
key
)
{
this
.
#expectString
(
key
);
...
...
@@ -755,7 +756,7 @@ export class TorController {
* @returns {Promise<string[]>} The values obtained from the control port.
* The key is removed, and the values unescaped, but they are not parsed.
* The array might contain an empty string, which means that the default value
* is used
.
* is used
*/
async
#getConf
(
key
)
{
this
.
#expectString
(
key
,
"
key
"
);
...
...
This diff is collapsed.
Click to expand it.
toolkit/components/tor-launcher/TorProvider.sys.mjs
+
11
−
8
View file @
0b146565
...
...
@@ -57,14 +57,14 @@ const logger = new ConsoleAPI({
* Stores the data associated with a circuit node.
*
* @typedef NodeData
* @property {NodeFingerprint} fingerprint The node fingerprint
.
* @property {string[]} ipAddrs
-
The ip addresses associated with this node
.
* @property {string?} bridgeType
-
The bridge type for this node, or "" if the
* @property {NodeFingerprint} fingerprint The node fingerprint
* @property {string[]} ipAddrs The ip addresses associated with this node
* @property {string?} bridgeType The bridge type for this node, or "" if the
* node is a bridge but the type is unknown, or null if this is not a bridge
* node
.
* @property {string?} regionCode
-
An upper case 2-letter ISO3166-1 code for
*
the
first ip address, or null if there is no region. This should also be a
* valid BCP47 Region subtag
.
* node
* @property {string?} regionCode An upper case 2-letter ISO3166-1 code for
the
* first ip address, or null if there is no region. This should also be a
* valid BCP47 Region subtag
*/
const
Preferences
=
Object
.
freeze
({
...
...
@@ -475,7 +475,8 @@ export class TorProvider {
/**
* Retrieve the list of private keys.
*
* @returns {OnionAuthKeyInfo[]}
* @returns {OnionAuthKeyInfo[]} The onion authentication keys known by the
* tor daemon
*/
async
onionAuthViewKeys
()
{
return
this
.
#controller
.
onionAuthViewKeys
();
...
...
@@ -483,6 +484,8 @@ export class TorProvider {
/**
* Returns captured log message as a text string (one message per line).
*
* @returns {string} The logs we collected from the tor daemon so far
*/
getLog
()
{
return
this
.
#logs
...
...
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