danog / php-rtc-stun
STUN transactions and NAT discovery for PHP, ported to Amp v3 sockets and fibers. MadelineProto's PHP 8.2+ fork supports the modular danog/php-rtc stack.
Fund package maintenance!
Requires
- php: ^8.2
- amphp/amp: ^3.1.3
- amphp/socket: ^2.4.1
- danog/php-rtc-exception: ^1.1.5
- danog/php-rtc-mixin: ^2.0
- psr/log: ^3.0.2
- ramsey/uuid: ^4.9.3
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.9.1
- dg/bypass-finals: dev-master
- mockery/mockery: ^1.6.15
- phpunit/phpunit: ^11.5 || ^12.0 || ^13.3.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A PHP library for STUN (Session Traversal Utilities for NAT) protocol, enabling NAT discovery and reflexive address retrieval for ICE connectivity in WebRTC applications.
About this fork
This is the danog/php-rtc-stun fork used by MadelineProto. It targets PHP 8.2+ and replaces ReactPHP with Amp v3 UDP sockets, blocking fiber APIs, and Revolt retransmission timers. Receive handlers run in separate fibers to avoid deadlocks, and socket addresses remain Amp\Socket\InternetAddress objects throughout the library.
All internal Composer dependencies use their danog/php-rtc-* package names directly, so installing a component selects the maintained danog packages throughout the dependency graph.
Features
- Encode and decode STUN messages
- Support for Binding requests and responses
- Implements STUN message integrity and fingerprinting
- Compatible with ICE and TURN components
Requirements
- PHP ≥ 8.2
Address API
All socket endpoints passed to or returned by the library use Amp\Socket\InternetAddress. This includes local and remote transport addresses, STUN request destinations, response source addresses, receiver callbacks, and address-valued STUN message attributes. Strings and [host, port] arrays are not accepted as socket endpoints.
Documentation
This package is part of the PHP WebRTC library. For complete documentation, examples, and API reference, visit:
Credits
Authors
-
Amin Yazdanpanah
- Website: aminyazdanpanah.com
- Email: github@aminyazdanpanah.com
-
Sana Moniri
- GtiHub: sanamoniri
Reporting Issues
Found a bug? Please report it on our issues.
License
BSD 3-Clause License. See LICENSE for details.