Trac: Summary: Make Torbutton work with SocksSocket option to Make Torbutton work with Unix Domain Socket option Description: Even if it is only for *NIX systems first, we should modify Torbutton to work with the SocksSocket option.
to
Even if it is only for *NIX systems first, we should modify Torbutton to work with the Unix Domain Socket option.
As far I understand, this is up to Make Tor Launcher work with Unix Domain Socket option (#14272 (moved)). What is Tor Button's role in this?
Torbutton includes code that interacts with tor via the control port (e.g., newnym, circuit display). If we disable all TCP in Tor Browser, control port communication will need to be via a Unix domain socket as well (so Torbutton will need to be modified).
let tlps = Cc["@torproject.org/torlauncher-protocol-service;1"] .getService(Ci.nsISupports).wrappedJSObject;
We should do that once and not twice in torbutton_init().
Checking whether we should call torbutton_local_tor_check() should check for
m_tb_control_socket_file as well (not only for m_tb_control_port) I guess?
I am not so sure about
+ } catch(e) {+ m_tb_control_port = 9151;+ }
What was your rationale for adding that now (given you omitted it earlier)? For one, the logs might be misleading showing a probably wrong port (I mean the setup is seriously troubling if we need to assign 9151 in the catch clause at all) in an error with respect to the control connection. On the other hand, we might want to show that something is wrong with the help of torbutton_do_tor_check() which would update the toolbar button in this case (if we get that far at all with a broken setup like the one in question).
Trac: Keywords: TorBrowserTeam201608R deleted, TorBrowserTeam201609 added Status: needs_review to needs_revision
{{{
+// given sockFile or host and port.
}}}
s/sockFile/socketFile/
Good catch.
{{{
let tlps = Cc["@torproject.org/torlauncher-protocol-service;1"]
.getService(Ci.nsISupports).wrappedJSObject;
}}}
We should do that once and not twice in torbutton_init().
Agreed.
Checking whether we should call torbutton_local_tor_check() should check for
m_tb_control_socket_file as well (not only for m_tb_control_port) I guess?
We did add that check, although if you look at the patch with git's default of three lines of context it is not so obvious.
I am not so sure about
{{{
} catch(e) {
m_tb_control_port = 9151;
}
}}}
What was your rationale for adding that now (given you omitted it earlier)? For one, the logs might be misleading showing a probably wrong port (I mean the setup is seriously troubling if we need to assign 9151 in the catch clause at all) in an error with respect to the control connection. On the other hand, we might want to show that something is wrong with the help of torbutton_do_tor_check() which would update the toolbar button in this case (if we get that far at all with a broken setup like the one in question).
Kathy and I added the 9151 default to be consistent with how m_tb_control_host is handled (it was already defaulting to 127.0.0.1). Thinking about this some more and looking at the existing Torbutton code, it seems like there is some effort to disable features (e.g., New Identity, the local Tor check) when the port is missing. So maybe we should put things back how there were and make sure we consistently check for port, password, etc. before trying to do things in Torbutton that require authenticated control port access?
The circuit display code also includes code that defaults the port to 9151, so if we decide to continue with the concept that a lack of port can be used to disable code, we should remove the || 9151 from this line in tor-circuit-display.js:
myController = controller(socketFile, host, port || 9151, password,
We can also add a check to skip the call to createTorCircuitDisplay() if port, password, etc. are missing (the existing code will log an error if initialization fails).
Checking whether we should call torbutton_local_tor_check() should check for
m_tb_control_socket_file as well (not only for m_tb_control_port) I guess?
We did add that check, although if you look at the patch with git's default of three lines of context it is not so obvious.
Hm. No, it is even obvious then. Must have been a different kind of code-blindness, my bad.
I am not so sure about
{{{
} catch(e) {
m_tb_control_port = 9151;
}
}}}
What was your rationale for adding that now (given you omitted it earlier)? For one, the logs might be misleading showing a probably wrong port (I mean the setup is seriously troubling if we need to assign 9151 in the catch clause at all) in an error with respect to the control connection. On the other hand, we might want to show that something is wrong with the help of torbutton_do_tor_check() which would update the toolbar button in this case (if we get that far at all with a broken setup like the one in question).
Kathy and I added the 9151 default to be consistent with how m_tb_control_host is handled (it was already defaulting to 127.0.0.1). Thinking about this some more and looking at the existing Torbutton code, it seems like there is some effort to disable features (e.g., New Identity, the local Tor check) when the port is missing. So maybe we should put things back how there were and make sure we consistently check for port, password, etc. before trying to do things in Torbutton that require authenticated control port access?
The circuit display code also includes code that defaults the port to 9151, so if we decide to continue with the concept that a lack of port can be used to disable code, we should remove the || 9151 from this line in tor-circuit-display.js:
myController = controller(socketFile, host, port || 9151, password,
We can also add a check to skip the call to createTorCircuitDisplay() if port, password, etc. are missing (the existing code will log an error if initialization fails).
What do you think?
I think we should not set m_tb_control_port to 9151 now in the catch clause and open a new ticket for implementing a saner solution across all Torbutton code. We can discuss there what we want that solution to be.
I think we should not set m_tb_control_port to 9151 now in the catch clause and open a new ticket for implementing a saner solution across all Torbutton code. We can discuss there what we want that solution to be.
I think we should not set m_tb_control_port to 9151 now in the catch clause and open a new ticket for implementing a saner solution across all Torbutton code. We can discuss there what we want that solution to be.
Sorry for the late review. This patch looks good to me -- nice work! I have a couple of minor stylistic suggestions that you may or may not want to adopt:
+// given socketFile or host and port.+io.asyncSocketStreams = function (socketFile, host, port) {+ let socketTransport;+ let sts = Cc["@mozilla.org/network/socket-transport-service;1"]+ .getService(Components.interfaces.nsISocketTransportService),+ UNBUFFERED = Ci.nsITransport.OPEN_UNBUFFERED;++ // Create an instance of a socket transport.+ if (socketFile) {+ socketTransport = sts.createUnixDomainTransport(socketFile);+ } else {+ socketTransport = sts.createTransport(null, 0, host, port, null);+ }+
Maybe move let socketTransport down to after the comment // Create an instance of a socket transport? Also, in that file, I had used blank lines to separate functions, though that's probably a personal eccentricity...
Also, a somewhat bigger suggestion that could be part of this patch or left for another time. In torbutton.js, we will now have
var m_tb_control_socket_file = null; // Set if using a UNIX domain socket. var m_tb_control_port = null; // Set if not using a socket. var m_tb_control_host = null; // Set if not using a socket. var m_tb_control_pass = null; var m_tb_control_desc = null;
I imagine it might be cleaner to collect these into a single data object like
var m_tb_control = { socket_file, host, port, password, descriptor }
Then we could factor out a single factory function from torbutton_init() that generates this object. And we could use this object as a single argument for functions in tor-control-port.js and tor-circuit-display.js as well.
Sorry for the late review. This patch looks good to me -- nice work! I have a couple of minor stylistic suggestions that you may or may not want to adopt:
{{{
+// given socketFile or host and port.
+io.asyncSocketStreams = function (socketFile, host, port) {
let socketTransport;
let sts = Cc["@mozilla.org/network/socket-transport-service;1"]
}}}
Maybe move let socketTransport down to after the comment // Create an instance of a socket transport?
Good idea.
Also, in that file, I had used blank lines to separate functions, though that's probably a personal eccentricity...
I am OK with accommodating eccentricities, but can you explain what we need to fix? I don't think we removed any blank lines, but maybe I am just not seeing it.
Also, a somewhat bigger suggestion that could be part of this patch or left for another time. In torbutton.js, we will now have
{{{
var m_tb_control_socket_file = null; // Set if using a UNIX domain socket.
var m_tb_control_port = null; // Set if not using a socket.
var m_tb_control_host = null; // Set if not using a socket.
var m_tb_control_pass = null;
var m_tb_control_desc = null;
}}}
I imagine it might be cleaner to collect these into a single data object like
{{{
var m_tb_control = { socket_file, host, port, password, descriptor }
}}}
Then we could factor out a single factory function from torbutton_init() that generates this object. And we could use this object as a single argument for functions in tor-control-port.js and tor-circuit-display.js as well.
Kathy and I like that suggestion, but let's do it as a follow up. I created #20102 (moved) for it.
Trac: Status: needs_review to needs_information Keywords: TorBrowserTeam201609R deleted, TorBrowserTeam201609 added
mcs/brade could you create an updated patch? I want to have this in the alpha as well. We can accommodate Arthur's remaining concerns (if there are any) in a fixup commit.
Okay, pushed to master commit 28a55f5bf324f43373006328c5b03793096f71c4. Arthur, let us know if we should make additional changes or just close this bug.