 All right, it's time for the most boring video you're ever gonna see on this channel. Today, we're gonna be talking about and setting up a turn server. So a turn server is just a little software, server software that connects two peers trying to do a WebRTC call. Now, what does that actually mean? Well, it means that if you're using Matrix or XMPP or some other self-hosted chat server, people are gonna wanna do peer-to-peer calls, video calls, voice calls, but that doesn't work unless you have a turn server to tell them each other's IPs. So that's what a turn server does. You ping the turn server, it responds using the stun protocol. It tells them, oh, here's the IP of your peer, the person you're trying to call, and then they can communicate. Now, sometimes that doesn't work and that's where the turn protocol comes into play that relays the information, the video and voice call information between the two users. And that's, of course, favorable if you're using, you know, a firewall or something else, which a lot of people are doing. Anyways, that's just a basic summary of how it works. Let's get into setting one up on Debian 10 using the co-turn turn server software. All right, so as you can see here, I got my Wiki article that's linked in the description if you wanna just follow a text guide. And over here, I got a Debian VPS. So that's one thing you will have to set up. You need some kind of server that's not behind an NAT. Some routers, if you have a home server, let you set up something called a DMZ. A DMZ is essentially giving your server the privileges to be beyond the NAT, which blocks ports and stuff. That's why you gotta port forward with most other applications. I've never seen a co-turn server work that's behind an NAT, so you have to set up either a DMZ that'll be in your router options, or just use a VPS, like on Vulture, Capsule, some other VPS provider. Now we can move on to the next part. So the installation, that's pretty easy. Debian repositories have co-turn in them, so just sudo apt install co-turn, pass dash wide and make it faster as well. Yeah, there you go, it's installed. Now moving on to basic configuration. Now those you can basically copy paste and then using VIM, so sudo vim, etsyturnserver.com. Now this file has a bunch of stuff in it already, and you can go through here and uncomment everything. I recommend just deleting everything because having a simple turn server configuration is gonna be excellent for debugging. So server name, that's easy, just name this turn dot whatever your website is. In my case, turn.denshi.org. My realm, that's just the same name as your server, so turn.denshi.org, in my case. You're listening IP. You wanna put your public IP in here, so let me just quit out of there and type IPA to get my public IP. There it is, inet 696138. It's the IP that I use for my turn server here, so going back into turnserver.com, I'm just gonna copy paste that here, and there you go. Because we're not behind in NAT, we can list it on a public IP, so that's all good. The listening port, you can keep this as is. Min port, you can keep it as is. Max port, you can keep it as is. Every other port is default, so you can just keep them like that. The verbose option is for debugging issues, we're gonna keep that on, and then scrolling down here, we have to pick an authentication method. Now turn servers, because they are relaying information, you have to have some kind of entity in the middle, now your Synapse server or your XMPP server that actually contacts it to set up the connection. And for that, you need authentication. Now in this case, we can use either usernames and passwords or an authentication secret. I'm gonna use an authentication secret because that's just simpler, but if you want, you can use a username and password. So copy paste these two lines over here to get the authentication secret, I'm gonna paste them into here. I'm gonna make the secret, I don't know, something stupidly insecure. Billy, one, two, three. There you go, there's my secret. It's just write quit over here. And now sudo system CTL, restart, coturn, and there you go, it's started. So now I'm gonna go and test out the actual calling on my server. Okay, so this is my config for eJabberty. And over here, there's a wiki article I wrote about how to set up eJabberty. I'll have this linked in the description so you can copy paste the part relating to turn servers. This little part over here, it's a configuration for the mod stun disco, which as the name implies, is a stun discovery modification. We're gonna delete this line that's over here and copy paste the configuration from my wiki, just making sure it's indented correctly. And we're gonna set our shared secret to Billy, one, two, three. We're gonna change our host to turn.denti.org or whatever host you're using. And now we can write and quit system CTL, restart eJabberty. And I'm gonna test the calling using my phone and this computer. But before I do that, let's take a look at how to set this up for your matrix server. So over here on the left, I'm in my home server.yaml file for the matrix Synapse server software. And as you can see, there's a turn section to configure the turn server. The turn your eyes, this is where you wanna put your actual domains. I'm gonna uncomment this. And over here, I'll also have this linked in the description. It's the Synapse turn server guide. And as you can see, they give an example of how to set it up. I'm gonna just copy paste these. Okay, I've copy pasted it. Basically you wanna change this to turn dot whatever it is that you're using. In my case, dentshi.org. Same thing for over here, dentshi.org. Then going to shared secret. This is obviously gonna be Billy, one, two, three. And I can uncomment this line. But anyways, I'm not gonna be testing this out on Synapse. I'm gonna be testing it out using eJabberty and XMPP with my phone and my computer. I'm not actually gonna write any of these changes. These are just informational for anybody who's using matrix and wants to set up voice and video calling. This is how you do it. All right, so I have a test account over here on Movin, which is an online XMPP client. And I have the same test account over here on my phone with just my regular account on blabber.im, which is a good XMPP client for phones. I'm gonna call this person from this phone. Audio call, there you go. There's the call. I'm gonna reply. Hey, this is a call. Yeah, there's an echo. I'll turn that off. But as you can see, the call was connected effectively and we were able to communicate. So that's proof that the turn server is actually working. Now let's take a look at what the logs look like when that's happening. Okay, so as you can see on the left over there, I got the turn server logs. I'm gonna try for another call. All right, I'm gonna reply. There you go. So that's just all the connections. I'm gonna turn this off. But that's the connections happening between me on the phone on a different IP address because I'm on mobile data and my computer over here, all being processed by the turn server. So this is what a good log should look like. And yeah, that's how you set up a co-turn server. That was my little article on it on the wiki. That's how you set it up for eJabberty. And Matrix, enjoy your WebRTC calling. I've been Denchie. Goodbye.