STUN Server | Long-Term Credentials

일반적으로 STUN 서버는 인증 없이 구성되므로 모든 STUN 클라이언트가 인증 없이 바인딩 요청을 보내고 서버로부터 응답을 받을 수 있습니다.

 

sgcWebSockets STUN Server는 Long-Term Credentials를 지원하므로, Long-Term 자격 증명 정보가 있는 바인딩 요청만 허용하도록 TsgcSTUNServer를 구성할 수 있습니다.

 

구성하려면 STUNOptions.Authorization 속성에 액세스하여 활성화하십시오.

그런 다음 LongTermCredentials 속성에 접근하여 활성화하십시오. 기본적으로 이 유형의 권한 부여는 Realm 문자열과 기본 StaleNonce 값 10분(= 600초)으로 이미 구성되어 있습니다.

 


oSTUN := TsgcSTUNServer.Create(nil);
oSTUN.Port := 3478;
oSTUN.STUNOptions.Authentication.Enabled := True;
oSTUN.STUNOptions.Authentication.LongTermCredentials.Enabled := True;
oSTUN.STUNOptions.Authentication.LongTermCredentials.Realm := 'sgcWebSockets';
oSTUN.STUNOptions.Authentication.LongTermCredentials.StaleNonce := 600;
oSTUN.Active := True;

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