TsgcTURNServer

TURN 服务器支持长期认证、Allocation、Permissions、Channel Data 等功能。

简介

TsgcTURNServer 是实现 TURN 协议的服务器端组件,用于处理来自 TURN 客户端的请求。该组件继承自 TsgcSTUNServer,因此 TsgcTURNServer 上可使用所有方法和属性。

 

TURN 服务器支持长期认证、Allocation、Permissions、Channel Data 等功能。

 

基本用法

通常 TURN 服务器在 UDP 端口 3478 上运行并需要长期凭证,因此若要配置 TURN 服务器,请设置侦听端口(默认 3478)并启动服务器。

 

配置服务器

 

将属性 Active = True 设置为启动 TURN 服务器。

 


    oTURN := TsgcTURNServer.Create(nil);
    oTURN.Port := 3478;
    oTURN.TURNOptions.Authentication.Enabled := True;
    oTURN.TURNOptions.Authentication.LongTermCredentials.Enabled := True;
    oTURN.TURNOptions.Authentication.LongTermCredentials.Realm := 'esegece.com';
    oTURN.Active := True;
    procedure OnSTUNRequestAuthorization(Sender: TObject; const aRequest: TsgcSTUN_Message; 
      const aUsername, aRealm: string; var Password: string);
    begin
      if (aUsername = 'user') and (aRealm = 'esegece.com') then
        Password := 'password';
    end;

参考

指南