STUN Server
Run your own STUN (RFC 8489) server in Delphi. Answer binding requests with the canonical XOR-MAPPED-ADDRESS reply — useful in private networks, on-premise deployments and ICE bootstrapping.
Run your own STUN (RFC 8489) server in Delphi. Answer binding requests with the canonical XOR-MAPPED-ADDRESS reply — useful in private networks, on-premise deployments and ICE bootstrapping.
A typed RFC 8489 STUN server — processes Binding / Indication messages, replies with XOR-MAPPED-ADDRESS, optionally enforces MESSAGE-INTEGRITY for long-term auth.
TsgcSTUNServer
Windows, macOS, Linux, iOS, Android
Enterprise
Set Port (default 3478), Active := True — your server now answers Binding requests with the canonical RFC 8489 XOR-MAPPED-ADDRESS reply.
uses
sgcP2P;
var
STUNServer: TsgcSTUNServer;
begin
STUNServer := TsgcSTUNServer.Create(nil);
STUNServer.Port := 3478;
// optional: long-term credentials
STUNServer.Authentication.Enabled := True;
STUNServer.Authentication.Realm := 'example.com';
STUNServer.OnSTUNAuthenticate := procedure(Sender: TObject;
const aUsername: string; var aPassword: string;
var Accept: Boolean)
begin
aPassword := LookupPassword(aUsername);
Accept := aPassword <> '';
end;
STUNServer.Active := True;
end;
// uses: sgcP2P
TsgcSTUNServer *STUNServer = new TsgcSTUNServer(this);
STUNServer->Port = 3478;
STUNServer->Active = true;
A self-hosted STUN server — ideal for on-premise WebRTC deployments and private-cloud testing.
Inbound Binding requests are answered with XOR-MAPPED-ADDRESS, MAPPED-ADDRESS (legacy) and FINGERPRINT — matching the standard RFC 8489 reply shape.
Toggle Authentication.Enabled to require MESSAGE-INTEGRITY. OnSTUNAuthenticate exposes the username from the request so you return the matching password from your store.
Combine with TsgcWSRateLimiter to throttle inbound STUN requests per source IP — useful protection against amplification abuse.
Bind to either family or dual-stack via IPVersion. The XOR-MAPPED-ADDRESS reply uses the family of the inbound transport.
For the STUN-over-TLS variant configure the underlying TCP listener with SSL options — useful when UDP is blocked at the network egress.
OnSTUNRequest / OnSTUNResponse log every transaction including Method, MessageType and the parsed attribute list — great for debugging deployments.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — TsgcSTUNServer Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\35.P2P\02.STUN Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |