www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - STUN/TURN servers

reply "Radu" <radu.margineanu gmail.com> writes:
I've seen vibe.d has some pretty nice features when it comes to 
asynchronous I/O but does someone know of an example of a 
STUN/TURN server written in it, or in plain D?
Apr 28 2014
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Monday, 28 April 2014 at 18:36:59 UTC, Radu wrote:
 I've seen vibe.d has some pretty nice features when it comes to 
 asynchronous I/O but does someone know of an example of a 
 STUN/TURN server written in it, or in plain D?
Every time I read anything related to STUN/TURN, it becomes obvious that these technologies were designed by some committee. Metric tons of technical jargon and bureaucratic overhead with an absurdly overcomplicated protocol to achieve such a simple thing. I implemented basic concept behind the TURN server, a TCP relay: http://worms2d.info/WormNAT2 The protocol is much simpler. As soon as a connection is received, it allocates a port and sends it to the client. This is the public port allocated for the connection - peers wishing to connect to the client can connect to that port on the relay server and talk as if they were talking to the client directly. Every time a peer connects, the server allocates a temporary port for the client to connect to, and sends it over the original control connection. After the client connects to said port, they can start talking to the peer directly, as if there's no proxy in-between. This avoids complicated handshakes, headers, and having to modify your protocol and wrap every single packet in a stupid header. It's also based on TCP, so you don't have to reimplement reordering, retransmission etc. on top of UDP all over again. It's not open-source, and although I could share the source code, it's not Vibe'd (D1 in fact). The implementation is very simple, though.
Apr 28 2014
parent reply "Radu" <radu.margineanu gmail.com> writes:
On Tuesday, 29 April 2014 at 01:21:36 UTC, Vladimir Panteleev 
wrote:
 On Monday, 28 April 2014 at 18:36:59 UTC, Radu wrote:
 Every time I read anything related to STUN/TURN, it becomes 
 obvious that these technologies were designed by some 
 committee. Metric tons of technical jargon and bureaucratic 
 overhead with an absurdly overcomplicated protocol to achieve 
 such a simple thing.

 I implemented basic concept behind the TURN server, a TCP relay:

 http://worms2d.info/WormNAT2

 The protocol is much simpler. As soon as a connection is 
 received, it allocates a port and sends it to the client. This 
 is the public port allocated for the connection - peers wishing 
 to connect to the client can connect to that port on the relay 
 server and talk as if they were talking to the client directly. 
 Every time a peer connects, the server allocates a temporary 
 port for the client to connect to, and sends it over the 
 original control connection. After the client connects to said 
 port, they can start talking to the peer directly, as if 
 there's no proxy in-between. This avoids complicated 
 handshakes, headers, and having to modify your protocol and 
 wrap every single packet in a stupid header. It's also based on 
 TCP, so you don't have to reimplement reordering, 
 retransmission etc. on top of UDP all over again.

 It's not open-source, and although I could share the source 
 code, it's not Vibe'd (D1 in fact). The implementation is very 
 simple, though.
Vibed is in D1? Are you sure? I can't seem to find any mention of that, it works with the current DMD, but then again I've never tried to compile a D1 program with it. Thhanks for you're answer, but I was looking for something a little more comprehensive, something that will work with WebRTC, that means binary or encoded messages, audio and video communication. It may seem hard to understand of you read the official documents but there are server examples written in C, C++, Java, Python, Erlang and node.js all open-source. I was hoping to find one written in D too. Oh well...
Apr 29 2014
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 29 April 2014 at 08:42:53 UTC, Radu wrote:
 On Tuesday, 29 April 2014 at 01:21:36 UTC, Vladimir Panteleev 
 wrote:
 On Monday, 28 April 2014 at 18:36:59 UTC, Radu wrote:
 Every time I read anything related to STUN/TURN, it becomes 
 obvious that these technologies were designed by some 
 committee. Metric tons of technical jargon and bureaucratic 
 overhead with an absurdly overcomplicated protocol to achieve 
 such a simple thing.

 I implemented basic concept behind the TURN server, a TCP 
 relay:

 http://worms2d.info/WormNAT2

 The protocol is much simpler. As soon as a connection is 
 received, it allocates a port and sends it to the client. This 
 is the public port allocated for the connection - peers 
 wishing to connect to the client can connect to that port on 
 the relay server and talk as if they were talking to the 
 client directly. Every time a peer connects, the server 
 allocates a temporary port for the client to connect to, and 
 sends it over the original control connection. After the 
 client connects to said port, they can start talking to the 
 peer directly, as if there's no proxy in-between. This avoids 
 complicated handshakes, headers, and having to modify your 
 protocol and wrap every single packet in a stupid header. It's 
 also based on TCP, so you don't have to reimplement 
 reordering, retransmission etc. on top of UDP all over again.

 It's not open-source, and although I could share the source 
 code, it's not Vibe'd (D1 in fact). The implementation is very 
 simple, though.
Vibed is in D1? Are you sure? I can't seem to find any mention of that, it works with the current DMD, but then again I've never tried to compile a D1 program with it.
No, he means that WormNAT2 is written in D1 and doesn't used Vibe.d Vibe.d is D2 only.
Apr 29 2014
parent "Radu" <radu.margineanu gmail.com> writes:
On Tuesday, 29 April 2014 at 09:56:18 UTC, John Colvin wrote:
 No, he means that WormNAT2 is written in D1 and doesn't used 
 Vibe.d

 Vibe.d is D2 only.
Thanks for the clarification :). It seems my English is a bit rusty.
Apr 29 2014