filepizza icon indicating copy to clipboard operation
filepizza copied to clipboard

Add ability to customize stun/turn server

Open iamdoubz opened this issue 8 months ago • 4 comments

This PR is for user's who already have a working turn server setup and enables the ability to customize the stun/turn servers through environmental variables. Resolves #241

New variables

  • STUN_HOST: HOSTNAME of the stun server. Defaults to stun.l.google.com
  • STUN_PORT: PORT of the stun server. Defaults to 19302
  • TURN_HOST: HOSTNAME of the turn server. Defaults to 127.0.0.1
  • TURN_TRANS: TRANSPORT of the turn server. Three options: both, udp, or tcp. Defaults to both
  • TURN_CRED: CREDENTIAL of the turn server. If current turn server utilizes a "Long term credential" mechanism, supply your key here. Default is empty
  • TURN_PORT: PORT of the turn server. Defaults to 3478
  • TURNS_PORT: PORT of the turns server. Defaults to 5349

iamdoubz avatar Apr 04 '25 18:04 iamdoubz

What about read a fully customized ice server json from env. We can add internal coturn configuation after decoding if needed.

Mmx233 avatar Apr 09 '25 08:04 Mmx233

I like the idea, but for my use case which is long term cred, the username and password are generated after you upload a file and press start. So you couldn't pass in a full ICE config that had any LTC attached to it.

iamdoubz avatar Apr 09 '25 12:04 iamdoubz

You are right. When customizing the config for the TURN server that filepizza can interact with, these fields are useful. And I agree that setting credentials through Redis is much safer.

But in my scenario, I need to use TURN servers in various geolocations. I can use virtual networking to protect the Redis connection across servers, but it seems like interacting with more than one TURN server is currently not supported.

Using a variable to input JSON can make the configuration more concise. At the same time, we can use something like mustache to render the credentials generated by filepizza into the configuration. This approach will offer both convenience and greater flexibility. If possible, please let me know, and I'm willing to make these modifications base on this branch.

[
    {
        "urls": "turn:xx.xx.com:3478",
        "username": "${{username}}",
        "credential": "${{password}}"
    },
    {
        "urls": "turn:xx.xx2.com:3478",
        "username": "StaticUsername",
        "credential": "StaticPassword"
    },
    {
        "urls": "stun:stun.l.google.com:19302"
    }
]

Mmx233 avatar Apr 10 '25 07:04 Mmx233

@Mmx233 If you have time to look into it, I'd say go for it. In general though, I don't think it is wise to use more than one turn server as it can cause performance issues. I don't remember where I read that so maybe it is old info.

iamdoubz avatar Apr 11 '25 20:04 iamdoubz