Componente de servidor TURN para Delphi e C++ Builder | eSeGeCe

TURN Server

Run your own TURN (RFC 8656) server in Delphi. Allocate relayed transport addresses for clients that cannot establish a peer-to-peer path, with long-term credentials and per-allocation quotas.

TsgcTURNServer

A self-hosted TURN server — processes Allocate / CreatePermission / ChannelBind / Send / Refresh / Data, manages allocations and bandwidth, validates long-term credentials.

Classe do componente

TsgcTURNServer

Protocolo

TURN (RFC 8656)

Plataformas

Windows, macOS, Linux, iOS, Android

Edição

Enterprise

Drop, set realm, hand out credentials

Set Port + Realm, supply per-user passwords via OnTURNAuthenticate, Active := True — your server now allocates relays for any RFC 8656 client.

uses
  sgcP2P;

var
  TURNServer: TsgcTURNServer;
begin
  TURNServer := TsgcTURNServer.Create(nil);
  TURNServer.Port  := 3478;
  TURNServer.Realm := 'turn.example.com';

  TURNServer.OnTURNAuthenticate := procedure(Sender: TObject;
    const aUsername: string; var aPassword: string;
    var Accept: Boolean)
  begin
    aPassword := LookupPassword(aUsername);
    Accept    := aPassword <> '';
  end;

  TURNServer.Active := True;
end;
// usa: sgcP2P
TsgcTURNServer *TURNServer = new TsgcTURNServer(this);
TURNServer->Port  = 3478;
TURNServer->Realm = "turn.example.com";
TURNServer->Active = true;

O que tem por dentro

A self-hosted relay — lets your WebRTC and ICE deployments stop depending on third-party TURN providers.

Allocate / Refresh / Free

Honours Allocate requests with REQUESTED-TRANSPORT, picks a free relay port and tracks lifetime. Refresh extends the allocation; the server tears it down on expiry.

CreatePermission / ChannelBind

Tracks per-allocation peer permissions and channel bindings. Drops Send/Data frames for peers that have not been permissioned per RFC 8656 §9.

Send / Data / ChannelData

Both 36-byte Send / Data envelopes and 4-byte ChannelData frames are supported. The relay forwards datagrams between the relayed-transport-address and the bound peer.

Long-term credentials

OnTURNAuthenticate exposes the username; you return the password — the server validates MESSAGE-INTEGRITY and rotates nonces automatically.

Quotas

Set Quota.MaxAllocationsPerUser, Quota.MaxBandwidthKbps, Quota.AllocationLifetime to bound abuse. OnQuotaExceeded reports rejections.

TURN over TCP / TLS

Toggle the underlying server's transport — UDP, TCP and TLS over TCP are all supported. WebRTC clients pick whichever traverses their NAT.

Especificações & referências

Fontes oficiais do protocolo que este componente implementa.

Documentação & Demos

Acesse a referência do componente, pegue o projeto demo pronto para executar e baixe a versão de avaliação.

Ajuda online — TsgcTURNServer Referência completa de propriedades, métodos e eventos deste componente.
Projeto demo — Demos\35.P2P\03.TURN Exemplo pronto para executar. Acompanha o pacote sgcWebSockets — baixe a versão de avaliação abaixo.
Documento técnico (PDF) Recursos, início rápido, exemplos de código para Delphi & C++ Builder e referências de fontes primárias — somente deste componente.
Manual do usuário (PDF) Manual completo cobrindo todos os componentes da biblioteca.

Perguntas frequentes sobre o servidor TURN

Dúvidas comuns sobre executar um relay TURN auto-hospedado em Delphi e C++ Builder.

Coloque um componente TsgcTURNServer, defina Port e Realm, forneça senhas por usuário a partir do evento OnTURNAuthenticate e, em seguida, defina Active := True. O servidor então trata Allocate, CreatePermission, ChannelBind, Send, Refresh e Data para qualquer client RFC 8656, retransmitindo datagramas entre o endereço de transporte retransmitido e o peer vinculado.
Ele implementa TURN conforme a RFC 8656, validando credenciais de longo prazo com MESSAGE-INTEGRITY e rotacionando nonces automaticamente. Ele também referencia a RFC 6062 para alocações TURN sobre TCP e a RFC 8489 para o formato de mensagem STUN subjacente, e suporta transportes UDP, TCP e TLS sobre TCP.
Não. TsgcTURNServer é um relay auto-hospedado que você incorpora no seu próprio aplicativo Delphi ou C++ Builder, de modo que suas implantações WebRTC e ICE podem deixar de depender de provedores TURN de terceiros ou de uma instalação coturn separada. Cotas por alocação (máximo de alocações por usuário, largura de banda e tempo de vida) limitam o abuso, com OnQuotaExceeded reportando as rejeições.
O servidor TURN faz parte da edição Enterprise do sgcWebSockets e suporta do Delphi 7 até o mais recente lançamento do Delphi e as versões correspondentes do C++ Builder, no Windows, macOS, Linux, iOS e Android. Baixe a versão de avaliação gratuita para colocar de pé um relay TURN no seu próprio projeto.

Ready to Run Your Own TURN Server?

Download the free trial and stand up a TURN relay in Delphi.