rsipstack - A SIP Stack written in Rust
A RFC 3261 compliant SIP stack written in Rust. The goal of this project is to provide a high-performance, reliable, and easy-to-use SIP stack that can be used in various scenarios.
Features
- RFC 3261 Compliant: Full compliance with SIP specification
- Multiple Transport Support: UDP, TCP, TLS, WebSocket
- Transaction Layer: Complete SIP transaction state machine
- Dialog Layer: SIP dialog management
- Digest Authentication: Built-in authentication support
- High Performance: Built with Rust for maximum performance
- Easy to Use: Simple and intuitive API design
TODO
- Transport support
- UDP
- TCP
- TLS
- WebSocket
- Digest Authentication
- Transaction Layer
- Dialog Layer
- WASM target
Use Cases
This SIP stack can be used in various scenarios, including but not limited to:
- Integration with WebRTC for browser-based communication, such as WebRTC SBC.
- Building custom SIP proxies or registrars
- Building custom SIP user agents (SIP.js alternative)
Why Rust?
We are a group of developers who are passionate about SIP and Rust. We believe that Rust is a great language for building high-performance network applications, and we want to bring the power of Rust to the SIP/WebRTC/SFU world.
Quick Start Examples
SIP Proxy Server
A stateful SIP proxy that routes calls between registered users:
# Run proxy server
# Run with external IP
This example demonstrates:
- SIP user registration and location service
- Call routing between registered users
- Transaction forwarding and response handling
- Session management for active calls
- Handling INVITE, BYE, REGISTER, and ACK methods
SIP User Agent Client
A complete SIP client with registration, calling, and media support:
# Local demo proxy
# Register with a SIP server
This example demonstrates:
- SIP user registration with digest authentication
- Making and receiving SIP calls (INVITE/BYE)
- Dialog management for call sessions
- RTP media streaming with file playback
- STUN support for NAT traversal
API Usage Guide
1. Simple SIP Connection
use ;
// Create UDP connection
let connection = create_connection.await?;
// Send raw SIP message
let sip_message = "OPTIONS sip:test@example.com SIP/2.0\r\n...";
connection.send_raw.await?;
2. Using New Listener APIs
use ;
use CancellationToken;
use unbounded_channel;
// Create TCP listener
let socket_addr: SocketAddr = "127.0.0.1:5060".parse?;
let local_addr = new;
let tcp_listener = new.await?;
let cancel_token = new;
let = unbounded_channel;
// Start TCP listener
tcp_listener.serve_listener.await?;
// Create WebSocket listener
let ws_local_addr = new;
let ws_listener = new.await?;
ws_listener.serve_listener.await?;
// Create TLS listener with configuration
let tls_config = TlsConfig ;
let tls_local_addr = new;
let tls_listener = new.await?;
tls_listener.serve_listener.await?;
// Handle incoming connections
while let Some = receiver.recv.await
3. Using Endpoint and Transactions
use ;
use CancellationToken;
// Build endpoint with transport layer
let cancel_token = new;
let transport_layer = new;
let endpoint = new
.with_transport_layer
.with_cancel_token
.build;
// Handle incoming transactions
let mut incoming = endpoint.incoming_transactions;
while let Some = incoming.recv.await
4. Creating a User Agent Client
use ;
use Credential;
use InviteOption;
use Arc;
use unbounded_channel;
// Create dialog layer
let dialog_layer = new;
// Register with server
let credential = Credential ;
let mut registration = new;
let response = registration.register.await?;
// Make outgoing call
let invite_option = InviteOption ;
let = unbounded_channel;
let = dialog_layer.do_invite.await?;
5. Implementing a Proxy
use ;
use RsipHeadersExt;
use HeadersExt;
use HashMap;
// Handle incoming requests
while let Some = incoming.recv.await
Running Tests
Unit Tests
Benchmark Tests
# Run server
# Run client with 1000 calls
The test monitor:
===
============================
Documentation
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.