pion / turn

Pion TURN, an API for building TURN clients and servers
MIT License
1.86k stars 317 forks source link

Help Wanted: Example for tls turn client ( pion webrtc ) #396

Closed RohanDoshi21 closed 5 months ago

RohanDoshi21 commented 6 months ago

The example mentioned in turn-server/tls let's me configure TLS enabled turn server.

I am using pion/webrtc, where I am providing it to the ICEServer, how can I enable TLS here ?

rg0now commented 6 months ago

Here's a snippet of code to use a TURN server over TLS in pion/webrtc:

// Set the ICE server config
config := webrtc.Configuration{
    ICEServers: []webrtc.ICEServer{
        {
            URLs: []string{"turns:<TURN_SERVER_IP_ADDRESS>:<TURN_SERVER_PORT>?transport=tcp"},
            Username: "<USERNAME>",
            Credential: "<PASSWORD>",
        },
    },
}

// Create a new RTCPeerConnection
peerConnection, err := api.NewPeerConnection(config)

For the specification of the TURN URI format see the RFC here. Plus there are millions of examples on how to use pion/webrtc here.