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

Browser doesn't connect to TOR on initial launch. #14517

Closed
GeetaSarvadnya opened this issue Jun 22, 2018 · 5 comments
Closed

Browser doesn't connect to TOR on initial launch. #14517

GeetaSarvadnya opened this issue Jun 22, 2018 · 5 comments

Comments

@GeetaSarvadnya
Copy link
Collaborator

GeetaSarvadnya commented Jun 22, 2018

Description

Browser doesn't connect to TOR on initial launch.

Test plan / Steps to Reproduce

  1. Launch brave with clean profile from console
  2. Open new private tab
  3. Enable TOR switch
  4. Observe the pop up with Disable tor and Restart brave options
  5. Verify console - it throws an error

Actual result:
Browser doesn't connect to TOR on initial launch.
tor- new profile launch from console issue

Expected result:
Browser should connect to TOR on initial launch.

Reproduces how often:
100%

Brave Version

0.23.14

about:brave info:

Brave: 0.23.14
V8: 6.7.288.46
rev: f4da855
Muon: 7.1.1
OS Release: 10.0.17134
Update Channel: Beta
OS Architecture: x64
OS Platform: Microsoft Windows
Node.js: 7.9.0
libchromiumcontent: 67.0.3396.87

Reproducible on current live release:
No

Additional Information

follow up to 14503 issue

@bsclifton
Copy link
Member

I believe this is Windows only - works great on macOS and Linux. On Windows when connecting, I get the following via stdout:

tor: control socket error: Error: connect ECONNREFUSED 127.0.0.1:52408
tor: control socket closed early

When looking at the tor logs though, version 3.3.7 is used and it appears to launch successfully

@bsclifton
Copy link
Member

bsclifton commented Jun 22, 2018

After receiving the above, I manually deleted the C:\Users\brian\AppData\Roaming\brave-beta\tor\watch\controlport file and relaunched. It took 2 attempts, but now Tor is being initialized properly

1st relaunch (which did not work) had the following on stdout:

tor: tossing stale cookie

2nd relaunch (which does work) has this output via stdout

tor: daemon listens on 127.0.0.1:9260
tor still not ready
Tor ready!

Subsequent relaunches do not work ☹️

@riastradh-brave
Copy link
Contributor

Can you share, from two consecutive runs, the following things?

  1. console output
  2. content of %appdata%\brave\tor\data\tor.log
  3. content of %appdata%\brave\tor\data\controlport or %appdata%\brave\tor\data\controlport.ack

riastradh-brave added a commit that referenced this issue Jun 22, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
riastradh-brave added a commit that referenced this issue Jun 22, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
diracdeltas pushed a commit that referenced this issue Jun 22, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
@bsclifton
Copy link
Member

Fixed with #14526

bsclifton pushed a commit that referenced this issue Jun 23, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
@srirambv
Copy link
Collaborator

Verified on Windows 10 x64 using

  • 0.23.16 - 2042c45
  • Muon - 7.1.1
  • libchromiumcontent - 67.0.3396.87

bsclifton pushed a commit that referenced this issue Jun 25, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
bsclifton pushed a commit that referenced this issue Jun 26, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
bsclifton pushed a commit that referenced this issue Jun 27, 2018
The tor daemon writes the control port first, and then the auth
cookie.  Currently we _read_ them in that order too, which means the
following sequence of events might happen:

1. tor writes controlport
2. we read new controlport
3. we read stale control_auth_cookie and give up
4. tor writes control_auth_cookie

Because I inexplicably wasn't thinking about it earlier, I put in two
kludges to work around this:

- We check the mtimes on the control port and control_auth_cookie,
  which is the basis on which we give up in step (2).  Alone, this
  would be harmless, but:

- We rename controlport to controlport.ack so we never read a stale
  version -- but that means if we give up on control_auth_cookie then
  we get wedged.

This changes brave to read the auth cookie first, and then the control
port.  If we successfully read the auth cookie, _then_ we are
guaranteed that the control port has been written, since the control
port write happens before the auth cookie write.

Since the read order is correct now, the kludges should be safely
eliminable and the logic simplified.  However, I will defer that
simplification to a subsequent change.

fix #14517

Auditors: @diracdeltas @bsclifton

Test Plan:
1. Launch Brave.
2. Confirm private tabs with Tor work.
3. Exit Brave.
4. Relaunch Brave.
5. Confirm private tabs with Tor still work.

The symptom that this fixes is that in step (5), Brave thinks that
Tor can't connect to the network, but the tor daemon reports in
$BRAVE/tor/dta/tor.log that it did successfully connect to the
network.

This seems to happen only on Windows.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.