Skip to content

Add ability to customize stun/turn server #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

iamdoubz
Copy link

@iamdoubz iamdoubz commented Apr 4, 2025

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 added 4 commits April 4, 2025 13:30
Add function for using TURN_CRED
Add stun variables: STUN_HOST/PORT; add turn variables: TURN_HOST/TRANS/CRED/PORT
Create an example file which will need to be renamed to `.env`
If coturn is not enabled, just use stun server fix
@Mmx233
Copy link

Mmx233 commented Apr 9, 2025

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

@iamdoubz
Copy link
Author

iamdoubz commented Apr 9, 2025

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.

@Mmx233
Copy link

Mmx233 commented Apr 10, 2025

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"
    }
]

@iamdoubz
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Long Term Credential
2 participants