Skip to content
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

Allow per-user TURN relay allocation #420

Open
enobufs opened this issue Nov 17, 2024 · 3 comments · May be fixed by #422
Open

Allow per-user TURN relay allocation #420

enobufs opened this issue Nov 17, 2024 · 3 comments · May be fixed by #422
Assignees

Comments

@enobufs
Copy link
Member

enobufs commented Nov 17, 2024

Summary

Current TURN server API allows us to customize how to allocate and create a net.PacketConn via ManagerConfig.AllocatePacketConn. This callback method however does not provide information of the TURN users for which the allocation was requested.

Motivation

TURN server is a middlebox where we could enforce policies such as how WebRTC traffic should be relayed. It could also be great place to run various diagnostic services. Allowing these services to be customizable per-user basis creates many business opportunities.

Describe alternatives you've considered

Per-process customization is possible but it is clunky and less flexible.

Additional context

classDiagram
    TURNServer --> UserManager: AuthHandler(username, realm)  
    TURNClient --> TURNServer: Allocate()  
    TURNServer --> RelayAddressGenerator: AllocatePacketConn(username)
    RelayAddressGenerator --> UserManager: LookupUser(username)

    namespace user_code {
        class UserManager {
        }
        class RelayAddressGenerator {
        }
    }
end
Loading
@enobufs enobufs self-assigned this Nov 17, 2024
enobufs added a commit that referenced this issue Nov 18, 2024
enobufs added a commit that referenced this issue Nov 18, 2024
enobufs added a commit that referenced this issue Nov 18, 2024
Related to #420
@enobufs enobufs linked a pull request Nov 18, 2024 that will close this issue
enobufs added a commit that referenced this issue Nov 18, 2024
@rg0now
Copy link
Contributor

rg0now commented Nov 18, 2024

Interesting issue, and thanks for the PR too. Can you please elaborate a bit? What is the simplest use case imaginable that would rely on this feature?

I'm not nitpicking, just trying to find the justification for introducing a breaking change.

@enobufs
Copy link
Member Author

enobufs commented Nov 18, 2024

I use this feature in my project to use TURN server (pion/turn fork) as a network conditioner which is implemented inside the net.PacketConn AllocatePacketConn() returns. The associating a user with a specific allocation allows it to have different network settings (works as presets).

You can think of many applications:

  • Rate limiter per user
  • WebRTC traffic diagnostic service (the traffic is encrypted, but you can still tap into RTP/RTCP headers, STUN, etc)
  • Selective QA/intergarion tests/troubleshooting system

@enobufs
Copy link
Member Author

enobufs commented Nov 18, 2024

Once this feature lands, I'd be happy to add the TURN-based network conditioner to pion's offerings. I talked about this with @Sean-Der a while ago. FYI.

enobufs added a commit that referenced this issue Nov 20, 2024
enobufs added a commit that referenced this issue Nov 20, 2024
enobufs added a commit that referenced this issue Dec 16, 2024
enobufs added a commit that referenced this issue Dec 30, 2024
enobufs added a commit that referenced this issue Dec 30, 2024
enobufs added a commit that referenced this issue Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants