Normalmente, os Servidores TURN são configurados COM Autenticação para requisições TURN e sem Autenticação para requisições STUN.
O Servidor TURN do sgcWebSockets suporta Long-Term Credentials, então você pode configurar o TsgcTURNServer para permitir apenas requisições com informações de credenciais Long-Term.
Para configurá-lo, acesse a propriedade TURNOptions.Authorization e habilite-a.
Em seguida, acesse a propriedade LongTermCredentials e habilite-a. Por padrão, este tipo de autorização já vem configurado com uma string Realm e com um valor StaleNonce padrão de 10 minutos (= 600 segundos).
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;