TokTok / c-toxcore

The future of online communications.
https://tox.chat
GNU General Public License v3.0
2.23k stars 283 forks source link

Support WebRTC ? #597

Open SkyzohKey opened 6 years ago

SkyzohKey commented 6 years ago

It would be nice to support websockets as a transport layer with the network. I'm working on a fully cross-platform (Linux, Windows, OSX, Android, iOS, Web) client and I'd like the web version to use websockets. Would it be simple to do ?

cringeops commented 6 years ago

Websockets may leak data. It’s a bad choice for secure messaging.

SkyzohKey commented 6 years ago

No websocket = no web client...

SkyzohKey commented 6 years ago

Or at least WebRTC

SlugFiller commented 6 years ago

WebSockets are for client->server communications. You wouldn't be able to set up WebSocket server inside a browser, only a client. WebRTC is for P2P applications, as it only gives you grief during bootstrapping. I did have partial success experimenting with WebRTC where you manually copy and paste the handshake info between two browsers, so any existing peer can be used for a connection set-up. But it's still a bit more complex than "Here's the address. Connect. Have fun". The matchmaking peer needs to relay about 3 packets before the direct connection is established. This has to be considered when handing off peers during bootstrapping, or even during normal operations.

SkyzohKey commented 6 years ago

@SlugFiller So it is technically possible, right?

SlugFiller commented 6 years ago

@SkyzohKey Yes. There's even a library by Google for adding WebRTC to native apps. It would still be a heck of an undertaking, and basically be an extension to the protocol. And, as said, adjustment would need to be made for peer sharing to allow routing the WebRTC handshake if one of the peers is a WebRTC peer.

SkyzohKey commented 6 years ago

@SlugFiller Can you link that library please ?

SlugFiller commented 6 years ago

@SkyzohKey https://webrtc.org/native-code/native-apis/

Atavic commented 6 years ago

WebRTC leaks the IP of every computer connected to the network card interface.

SkyzohKey commented 6 years ago

@Atavic I'm aware of this, but Tox isn't an anonymity tool. Only a privacy one. + Web interface can be useful when traveling and you're one some free wifi. Not meant to be used as a main client. (See https://github.com/Tox-Client/client to understand why this is needed)

SkyzohKey commented 6 years ago

Any news about that ? @iphydf I'm going to start implementing js-toxcore-c to my Tox client and I'd really like to have first class support of webrtc on the web version. Else I'll have to setup some sort of centralized server that does handle Tox DHT for every user that logs in, then relay packet with webrtc. But I'm not too friand of that way because ''centralized'' is against Tox's principles. We need to get Tox in the hands of as many users as possible and webapp is a great acquisition channel because it allows to try the IM before installing it. Also, every popular messenger as a web version, and we need at least feature parity with them of we want Tox to be successful :)

I'd be glad to help implementing this, but I'd need someone to bootstrap me, I'm not so good with C so...

tox-user commented 6 years ago

@SkyzohKey I think you would have to somehow run toxcore in the browser?

SkyzohKey commented 6 years ago

I would have to implement the Tox protocol in JS, which I am willing to do, but for this to work toxcore needs to accept data from/to webrtc :)

sudden6 commented 6 years ago

@SkyzohKey you could also start to implement and run hybrid nodes to route data between normal c-toxcore and WebRTC toxcore, like https://github.com/webtorrent/webtorrent

SkyzohKey commented 6 years ago

@sudden6 that's an option but would be nice to have toxcore to handle that natively. But I light end using that ''hack'' until it's ready yes

SkyzohKey commented 6 years ago

Oh, and of course bootstrap nodes would need to handle signaling (webrtc to dht).

SlugFiller commented 6 years ago

Optimally, the use of WebRTC would be a mostly transparent layer beneath the main Tox protocol, allowing any two clients to use whichever they can/prefer, similar to how TLS is used. An unfortunate major difference is that WebRTC needs a bridging side channel during handshake, which inevitably requires a protocol extension (unless you want to try to mess with REST-WebRTC hybrid).

I reckon what @SkyzohKey needs, currently, as a pointer to the file/functions in which the Tox protocol (particularly the handshake) is performed. Unfortunately, I haven't the time to delve into another code base. But if someone wants to point me to a file, I can probably give it a 10-15 minutes look to find the points of interest.

r4de commented 5 years ago

Any news about an web solution? - That would push tox to life again ;)