Skip to main content

Crate fakepbx

Crate fakepbx 

Source
Expand description

In-process SIP server (UAS) for testing.

Wraps a UDP socket to create a real SIP server bound to 127.0.0.1 on an ephemeral port. Tests get full programmatic control over SIP call flows — REGISTER, INVITE, BYE, CANCEL, REFER, OPTIONS, INFO, MESSAGE, SUBSCRIBE — without Docker, external processes, or hardcoded ports.

§Basic usage

use fakepbx::{FakePBX, sdp};

let pbx = FakePBX::new(&[]);
pbx.on_invite(|inv| {
    inv.trying();
    inv.ringing();
    inv.answer(&sdp::sdp("127.0.0.1", 20000, &[sdp::PCMU]));
});
// Point your SIP UA at pbx.addr() and dial pbx.uri("1002")
// The server stops when the FakePBX is dropped.

Re-exports§

pub use recorded::RecordedRequest;
pub use handlers::*;

Modules§

handlers
SIP request handler types for FakePBX.
recorded
Request recording and inspection for FakePBX.
sdp
SDP helpers for FakePBX test scenarios.
sip
Minimal SIP message parsing and building for FakePBX.

Structs§

FakePBX
An in-process SIP UAS for testing.

Enums§

Opt
Configuration option for FakePBX.

Functions§

with_auth
Creates an Opt::Auth option.
with_transport
Creates an Opt::Transport option.
with_user_agent
Creates an Opt::UserAgent option.