matchbox icon indicating copy to clipboard operation
matchbox copied to clipboard

Add ice auth support

Open johanhelsing opened this issue 1 year ago • 2 comments

  • [x] expose api for setting authentication
  • [x] native implementation
  • [ ] wasm implementation
  • [ ] should credential and username be String or Option<String>?
  • [ ] document new api
  • [ ] implement From trait for new enum

Fixes #3

johanhelsing avatar Jul 24 '22 16:07 johanhelsing

should credential and username be String or Option<String>?

Had a quick look, what about something like this?

impl Default for RtcIceServerConfig {
    fn default() -> Self {
        Self {
            urls: vec![
                "stun:stun.l.google.com:19302".to_string(),
                //"stun:stun.johanhelsing.studio:3478".to_string(),
                //"turn:stun.johanhelsing.studio:3478".to_string(),
            ],
            credentials: Default::default(),
        }
    }
}
#[derive(Debug)]
pub struct RtcIcePasswordCredentials {
    username: String,
    credential: String,
}

#[derive(Debug)]
pub struct RtcIceOathCredentials {
    //Todo
}

#[derive(Debug)]
pub enum RtcIceCredentials {
    None,
    Password(RtcIcePasswordCredentials),
    Oauth(RtcIceOathCredentials),
}

impl Default for RtcIceCredentials {
    fn default() -> Self {
        RtcIceCredentials::None
    }
}

tedsteen avatar Jul 24 '22 20:07 tedsteen

Pushed my code as I had it lying around, note that target branch is turn-support, not main https://github.com/johanhelsing/matchbox/pull/38

tedsteen avatar Jul 25 '22 07:07 tedsteen

WDYT about my suggestion over here? https://github.com/johanhelsing/matchbox/pull/38

tedsteen avatar Oct 26 '22 08:10 tedsteen

@tedsteen I think this should be good to go now. I haven't tested it, though, as I don't have a turn server running. Would you mind testing both implementations with yours?

johanhelsing avatar Oct 27 '22 07:10 johanhelsing

I've been using a hosted solution https://xirsys.com/ for my turn needs and I've tried the RtcIceCredentials::Password on that and they work fine.

I've also tried the IceCredentials::None and they still work :)

tedsteen avatar Oct 27 '22 07:10 tedsteen

@tedsteen Thanks!

johanhelsing avatar Oct 27 '22 07:10 johanhelsing

@tedsteen have you a working example of how to use a TURN server? I am currently trying to figure out how this works but I am a little lost and could need a reference point.

PraxTube avatar Oct 22 '23 12:10 PraxTube

@tedsteen have you a working example of how to use a TURN server? I am currently trying to figure out how this works but I am a little lost and could need a reference point.

Hi! Here is an example where I use turn servers with credentials https://github.com/tedsteen/nes-bundler/blob/4df0f60cc1866547d5d553c66089bfc4f7c1263e/src/netplay/connecting_state.rs#L207

For the servers themselves I use a service https://xirsys.com They have a really nice free tier that will be enough for most of your needs for sure if you are using it for ggrs.

tedsteen avatar Oct 22 '23 13:10 tedsteen

Thanks! I appreciate the fast reply. Yeah xirsys looks pretty good.

PraxTube avatar Oct 22 '23 13:10 PraxTube