Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

churn doesn't work between chrome and firefox #1597

Closed
trevj opened this issue Jun 1, 2015 · 13 comments
Closed

churn doesn't work between chrome and firefox #1597

trevj opened this issue Jun 1, 2015 · 13 comments
Assignees
Labels

Comments

@trevj
Copy link
Contributor

trevj commented Jun 1, 2015

Simple SOCKS with churn works fine, but not uProxy. Seems to be just Firefox, and it seems to be related to the timing of ICE candidates: the obfuscated connection times out while the probe connection is still generating signalling messages. Weird!

However, this happens even if I specify no STUN servers -- there's clearly more going on here.

@trevj trevj added this to the v-focus-2015-06-08 milestone Jun 1, 2015
@bemasc bemasc self-assigned this Jun 1, 2015
@bemasc
Copy link
Contributor

bemasc commented Jun 2, 2015

The first issue I found is that onicecandidate(null) (indicating the end of gathering) can be greatly delayed in Firefox, firing later than the 5 second timeout for receiving the first ICE candidate. This causes the obfuscated connection go to the "failed" state.

After introducing a workaround (a 3 second timer to stop waiting for onicecandidate(null)) the connection still doesn't work, even when connecting to an external host (to avoid hairpinning issues). I'm not sure why it still doesn't work. This time, the connection fails when our own timeout kills SocksToRtc.

@trevj trevj changed the title churn doesn't work in uproxy on firefox churn doesn't work between chrome and firefox Jun 5, 2015
@trevj
Copy link
Contributor Author

trevj commented Jun 5, 2015

Have been digging into this. Firefox -> Firefox works just fine, as does Chrome -> Chrome.

There's something about the way we mangle candidate lines that is incompatible with how Chrome produces them, and how Firefox consumes them.

So far, I've tried a few things:

  1. have churn-pipe explicitly bind to 127.0.0.1
  2. send only one candidate line to the underlying (obfuscated) peerconnection

Not much success yet, though.

@trevj
Copy link
Contributor Author

trevj commented Jun 5, 2015

Oh, another thing: the set of STUN servers specified by uProxy takes ~10 seconds to complete gathering on Chrome. We need to dig into this, too. Reckon there'll be several things required to fix this.

@trevj trevj assigned trevj and unassigned bemasc Jun 5, 2015
@trevj
Copy link
Contributor Author

trevj commented Jun 10, 2015

So, Firefox doesn't like to act as a prflx candidate on 127.0.0.1.

Specifically, if WebRTC A (on Firefox) is communicating with a WebRTC B who reports A's address as 127.0.0.1 then Firefox's WebRTC A will not establish a connection with B. Wireshark can be used to identify this issue: you will see STUN messages with XOR-MAPPED-ADDRESS of 127.0.0.1 passed back to Firefox's WebRTC port.

With the current code, this happens when a uProxy running under Firefox attempts to connect with uProxy running on Chrome. Chrome respects the 127.0.0.1 supplied to churn-pipe but it turns out freedom-for-firefox always binds to *:
https://github.com/freedomjs/freedom-for-firefox/blob/master/providers/core.udpsocket.js#L13

If I change that second argument to init to true, then Simple SOCKS on Firefox no longer works.

The easiest fix is to have churn-pipe bind to a non-127.0.0.1 address; we can just bind to the same address/interface as the obfuscated WebRTC connection. For bonus points (extra security, for those having public IPs) the pipe really should only accept packets from the obfuscated WebRTC connection's address and port.

@bemasc
Copy link
Contributor

bemasc commented Jun 10, 2015

The easiest fix is to have churn-pipe bind to a non-127.0.0.1 address

Well, as you pointed out, it looks like our implementation of bind in Firefox ignores this address anyway. Do we have to fix that first?

@trevj
Copy link
Contributor Author

trevj commented Jun 10, 2015

We may not need any fix on the Firefox side -- AFAICT, calling init with second argument false means "bind to all interfaces":
https://dxr.mozilla.org/mozilla-central/source/netwerk/base/nsUDPSocket.cpp#762

@bemasc
Copy link
Contributor

bemasc commented Jun 10, 2015

Right. Is it then guaranteed that packets sent to some interface will see that same interface as the source address? I'm not aware of any such guarantee. AFAIK, the implementation could still set the source address to localhost.

@trevj
Copy link
Contributor Author

trevj commented Jun 10, 2015

A little more info on INADDR_ANY:

Right, I see no guarantee that your source address for packets won't be 127.0.0.1 -- but Wireshark tells me this isn't happening right now. I will file an issue to investigate further.

@trevj
Copy link
Contributor Author

trevj commented Jun 10, 2015

Let's:

  • file an issue for freedom-for-firefox to actually bind to the requested address (right now for me it's fine but there's no guarantee that's true everywhere)
  • bind mirror ports to 0.0.0.0 (I just tested this, seems to work nicely)
  • have mirror ports accept traffic only from WebRTC

@bemasc
Copy link
Contributor

bemasc commented Jun 10, 2015

OK, filed freedom-for-firefox issue: freedomjs/freedom-for-firefox#67

@trevj
Copy link
Contributor Author

trevj commented Jun 10, 2015

And the fix to bind to 0.0.0.0:
UWNetworksLab/uProxy-lib#196

@bemasc
Copy link
Contributor

bemasc commented Jun 10, 2015

We now understand that this is a deliberate choice in Firefox, albeit not one that was deliberated at great length. It's possible that we could get a change to Firefox's behavior here, but given that Firefox 38 will be the Extended Support Release for two years, I think it behooves us to focus on making our code work in that version.

For context see the chat log on this topic.

@trevj
Copy link
Contributor Author

trevj commented Jun 10, 2015

I think this is the major outstanding TODO:
#1631

@trevj trevj closed this as completed Jun 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants