TURN Server | Credenziali a lungo termine

Di solito i server TURN sono configurati CON autenticazione per le richieste TURN e senza autenticazione per le richieste STUN.

 

sgcWebSockets TURN Server supporta le credenziali a lungo termine, quindi è possibile configurare TsgcTURNServer per consentire solo le richieste con informazioni sulle credenziali a lungo termine.

 

Per configurarlo, accedere alla proprietà TURNOptions.Authorization e abilitarla.

Quindi acceda alla proprietà LongTermCredentials e la abiliti. Per impostazione predefinita, questo tipo di autorizzazione è già configurato con una stringa Realm e con un valore StaleNonce predefinito di 10 minuti (= 600 secondi).

 


oTURN := TsgcTURNServer.Create(nil);
oTURN.Port := 3478;
oTURN.STUNOptions.Authentication.Enabled := False;
oTURN.TURNOptions.Authentication.Enabled := True;
oTURN.TURNOptions.Authentication.LongTermCredentials.Enabled := True;
oTURN.TURNOptions.Authentication.LongTermCredentials.Realm := 'sgcWebSockets';
oTURN.TURNOptions.Authentication.LongTermCredentials.StaleNonce := 600;
oTURN.Active := True;

procedure OnSTUNRequestAuthorization(Sender: TObject; const aRequest: TsgcSTUN_Message; 
  const aUsername, aRealm: string; var Password: string);
begin
  if (aUsername = 'my-user') and (aRealm = 'sgcWebSockets') then
    Password := 'my-password';
end;