How to use a Gun Server as a relay only?
Asked Answered
C

1

6

Is there a way to setup the GUN-server as a relay only? In other words, is there a way to ensure data is shared peer-to-peer only? The server only acts a signal (STUN like) server. In the few tests I've done I can't seem to see the data go P2P, and seems to only funnel through the gun-server.

I want to make sure the server has no client DB data on it. Obviously, connection info and possibly DB names would be there.

Thank you.

Connoisseur answered 19/8, 2018 at 2:29 Comment(0)
O
7

@Jbjet777 great question!

You can drop in lib/webrtc into your browser app as an extension to get direct P2P messaging if WebRTC works.

By default GUN still relays via the relay peer to ensure reliability, as WebRTC historically has been very unreliable (although we do hope this lib/webrtc adapter is more reliable than other frameworks).

That said, it is possible to configure the setup you want you can manually call gun.back('opt.peers')[relay_peer_url].wire.close() (make sure calling this is safe, add if-checks and stuff) after your WebRTC sessions have been established.

Please hit up the chatroom if you want further help on doing this.

Also note, why do you want the relay peer to not help store/sync data? Is it perhaps because you want to keep the data private? That is possible to do with our SEA security layer which can do end-to-end encryption. Just in case this makes things easier for you!

Orrery answered 25/8, 2018 at 4:35 Comment(4)
Thanks for the answer. Yes I'm loving the SEA security layer. I see the webrtc.js file in the lib folder of the GIT repository, besides adding that, I'm not really seeing any documentation on enabling the WebRTC options?Connoisseur
@Connoisseur adding the file to your browser code automatically enables WebRTC. Unfortunately, documentation hasn't been written yet as it was only released last week... hopefully that'll happen soon! The code is quite short ( ~100 lines ish) so reading it should be easy / if you could contribute docs that would be a life saver!Orrery
I did start to peek at the code. I'm still getting used to some of the coding concepts used in this project, so for now, its a bit beyond me to doc it. I'm gonna get some other parts of my project smoothed out and swing back to this in a bit.Connoisseur
No worries, sorry for the lack of documentation - although, understanding WebRTC ICE candidate flow is very confusing. You can always jump on gitter.im/amark/gun super friendly community there. :)Orrery

© 2022 - 2024 — McMap. All rights reserved.