Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Question Unity WebRTC restrict DataChannel ports

Discussion in 'Unity Render Streaming' started by patrickk2, Dec 19, 2020.

  1. patrickk2

    patrickk2

    Joined:
    Dec 8, 2019
    Posts:
    92
    Hello everyone!

    For my project I would like to restrict the ports that can be used for DataChannels to a certain [min, max] range.

    Adding the respective properties to the
    RTCConfiguration
    was the easy part, now I need to add this to the Unity WebRTC plugin. If I am not mistaken, I should create my own
    cricket::BasicPortAllocator
    (for which I can set a port range) to the
    PeerConnectionDependencies
    . This is where I am having problems, since I do not have access to the objects needed to create one (i.e. the
    ConnectionContext
    ).

    I would very much like to avoid going another level deeper and patch this in the libwebrtc. Is there a way to create my own
    BasicPortAllocator
    for the dependencies? Or maybe a completely different way to restrict the port range?

    Thanks in advance for any input on this topic!

    Best regards,
    Patrick
     
  2. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
  3. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
  4. patrickk2

    patrickk2

    Joined:
    Dec 8, 2019
    Posts:
    92
    Hello Kazuki!

    The question is not from me, but I guess it is the same issue. I found via some detours, that the WebRTC implementation for nodejs, can do this (see the RTCPeerConnection constructor). As far as I can see, the Unity Plugin uses the same library and could use this port allocator, if one had access to the used network manager, and socket factory.

    Best regards,
    Patrick
     
  5. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    I have read the code you shared and make sure how to do it.
    I checked the method used in this code, it is already deprecated (link).
    I am investigating the other API to specify the port range.
     
  6. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803