Delphi TURN 서버

Delphi에서 자체 TURN(RFC 8656) 서버를 실행하세요. P2P 경로를 설정할 수 없는 클라이언트에게 중계 전송 주소를 할당하고, 장기 자격 증명과 할당별 할당량을 지원해요.

TsgcTURNServer

자체 호스팅 TURN 서버 — Allocate / CreatePermission / ChannelBind / Send / Refresh / Data를 처리하고, 할당과 그 수명을 관리하며, 장기 자격 증명을 검증해요.

컴포넌트 클래스

TsgcTURNServer

프로토콜

TURN (RFC 8656)

플랫폼

Windows, macOS, Linux, iOS, Android

에디션

Enterprise

컴포넌트를 놓고, 영역을 설정하고, 자격 증명을 발급

Port를 설정하고 렐름은 TURNOptions.Authentication.LongTermCredentials에 지정한 뒤, OnSTUNRequestAuthorization로 사용자별 비밀번호를 제공하고 Active := True 하세요 — 이제 서버가 모든 RFC 8656 클라이언트에 중계를 할당해요.

uses
  sgcP2P, sgcP2P_STUN_Classes;

// TFormTURNServer는 FServer: TsgcTURNServer와 핸들러를 보유

procedure TFormTURNServer.StartServer;
begin
  FServer := TsgcTURNServer.Create(nil);
  FServer.Port := 3478;

  FServer.TURNOptions.Authentication.Enabled := True;
  FServer.TURNOptions.Authentication.LongTermCredentials.Enabled := True;
  FServer.TURNOptions.Authentication.LongTermCredentials.Realm :=
    'turn.example.com';

  // 오용 방지: 사용자별 할당 수와 최대 수명 제한
  FServer.TURNOptions.Allocation.MaxUserAllocations := 4;
  FServer.TURNOptions.Allocation.MaxLifeTime := 3600;

  FServer.OnSTUNRequestAuthorization := OnSTUNRequestAuthorization;

  FServer.Active := True;
end;

procedure TFormTURNServer.OnSTUNRequestAuthorization(Sender: TObject;
  const aRequest: TsgcSTUN_Message;
  const aUsername, aRealm: string;
  var Password: string);
begin
  // 해당 사용자의 비밀번호를 반환, 빈 값이면 요청을 거부
  Password := LookupPassword(aUsername);
end;
// includes: sgcP2P.hpp, sgcP2P_STUN_Classes.hpp
TsgcTURNServer *Server = new TsgcTURNServer(this);
Server->Port = 3478;
Server->TURNOptions->Authentication->Enabled = true;
Server->TURNOptions->Authentication->LongTermCredentials->Enabled = true;
Server->TURNOptions->Authentication->LongTermCredentials->Realm = "turn.example.com";
Server->TURNOptions->Allocation->MaxUserAllocations = 4;
Server->OnSTUNRequestAuthorization = OnSTUNRequestAuthorization;
Server->Active = true;

내부 구성

자체 호스팅 중계 서버 — WebRTC 및 ICE 배포가 서드파티 TURN 공급자에 의존하지 않도록 해줘요.

Allocate / Refresh / Free

REQUESTED-TRANSPORT가 포함된 Allocate 요청을 처리하고 사용 가능한 중계 포트를 선택해 수명을 추적해요. Refresh는 할당을 연장하며, 만료 시 서버가 할당을 정리해요.

CreatePermission / ChannelBind

할당별 피어 권한과 채널 바인딩을 추적해요. RFC 8656 §9에 따라 권한이 부여되지 않은 피어의 Send/Data 프레임은 폐기해요.

Send / Data / ChannelData

36바이트 Send / Data 봉투와 4바이트 ChannelData 프레임을 모두 지원해요. 중계가 relayed-transport-address와 바인딩된 피어 사이에서 데이터그램을 전달해요.

장기 자격 증명

TURNOptions.Authentication.LongTermCredentials에 렐름이 담기고, OnSTUNRequestAuthorization가 사용자명과 그 렐름을 전달하므로 비밀번호를 반환하면 돼요. 서버가 MESSAGE-INTEGRITY를 검증하고 논스도 알아서 회전시켜요.

할당량과 중계 포트

TURNOptions.Allocation.MaxUserAllocations는 사용자 한 명이 받을 수 있는 중계 수를 제한하고, DefaultLifeTimeMaxLifeTime은 각 중계의 수명을 제한하며, MinPort / MaxPort / RelayIP는 중계 포트 범위를 고정해요. 한도를 넘은 사용자는 486 Allocation Quota Reached를 받아요.

모든 할당을 검사

OnTURNBeforeAllocate는 요청한 주소를 var Reject와 함께 전달하고, OnTURNBeforeRelayIndicationOnTURNBeforeRelayChannelData는 중계되는 모든 데이터그램에 대해 같은 일을 해요. OnTURNCreateAllocationOnTURNDeleteAllocation으로 살아 있는 할당을 추적해요.

명세 및 참고 자료

이 컴포넌트가 구현하는 프로토콜의 공인 출처예요.

문서 및 데모

컴포넌트 레퍼런스로 바로 이동하고, 바로 실행할 수 있는 데모 프로젝트를 받아보고, 체험판을 다운로드하세요.

온라인 도움말 — TsgcTURNServer 이 컴포넌트의 전체 속성, 메서드, 이벤트 레퍼런스예요.
데모 프로젝트 — Demos\35.P2P\03.TURN 바로 실행할 수 있는 예제 프로젝트예요. sgcWebSockets 패키지에 포함되어 있으니 아래에서 체험판을 다운로드해 보세요.
기술 문서 (PDF) 이 컴포넌트의 기능, 빠른 시작, Delphi 및 C++ Builder 코드 샘플, 출처 참고 자료예요.
사용자 설명서 (PDF) 라이브러리의 모든 컴포넌트를 다루는 종합 설명서예요.

TURN 서버 자주 묻는 질문

Delphi 및 C++ Builder에서 자체 호스팅 TURN 릴레이를 운영하는 것에 대해 자주 묻는 질문이에요.

TsgcTURNServer 컴포넌트를 추가하고, PortRealm을 설정하고, OnSTUNRequestAuthorization 이벤트에서 사용자별 비밀번호를 제공한 다음 Active := True로 설정하세요. 그러면 서버가 모든 RFC 8656 클라이언트에 대해 Allocate, CreatePermission, ChannelBind, Send, Refresh, Data를 처리하여, 릴레이된 전송 주소와 바인딩된 피어 사이에서 데이터그램을 중계해요.
RFC 8656에 따라 TURN을 구현하여, MESSAGE-INTEGRITY로 long-term 자격 증명을 검증하고 nonce를 자동으로 교체해요. 또한 TURN over TCP 할당을 위해 RFC 6062를, 기본 STUN 메시지 형식을 위해 RFC 8489를 참조하며, UDP, TCP, TLS over TCP 전송을 지원해요.
아니요. TsgcTURNServer는 직접 Delphi 또는 C++ Builder 애플리케이션에 내장하는 자체 호스팅 릴레이이므로, WebRTC 및 ICE 배포가 타사 TURN 제공업체나 별도의 coturn 설치에 의존하지 않을 수 있어요. 할당별 할당량(사용자당 최대 할당 수, 대역폭, 수명)으로 남용을 제한하며, OnQuotaExceeded가 거부를 보고해요.
TURN 서버는 sgcWebSockets Enterprise 에디션의 일부이며 Delphi 7부터 최신 Delphi 릴리스까지, 그리고 해당하는 C++ Builder 버전을 Windows, macOS, Linux, iOS, Android에서 지원해요. 무료 체험판을 다운로드하여 직접 프로젝트에서 TURN 릴레이를 구축해 보세요.
최고의 가성비: All-Access모든 eSeGeCe 제품과 프리미엄 지원이 포함되어 연 €1,059부터 이용할 수 있어요.
All-Access 가격 보기

자체 TURN 서버를 운영할 준비가 되셨나요?

무료 체험판을 다운로드하고 Delphi에서 TURN 중계 서버를 띄워보세요.