Skip to main content
Version: 2.5.x (dev)

Source / Input / Active

icecast.server

Start an icecast-compatible server

Type:

(?name : string, ?port : int, ?password : string, ?dedicated_encoder : bool,
?x_forwarded_for_proxy_ips : [string?]?,
?x_forwarded_for : ((
{
headers : [string * string],
ip : string?,
protocol : string,
proxy_ips : [string?],
uri : string
}) -> string?)?,
?format_options : ((string) -> [string * string])?, ?config : string?,
?serve : bool,
?serve_auth : ((
{
body : (?timeout : float) -> string,
data : (?timeout : float) -> string,
headers : [string * string],
http_version : string,
method : string,
path : string,
query : [string * string]
}) -> bool)?,
?serve_json : (([string *
{
content_type : string,
current_metadata : [string * string],
listeners : [
{
ip : string,
protocol : string,
uri : string
}],
mime_type : string?,
name : string,
peak_listeners : int,
started : float
}]) -> string)?,
?serve_html : (([string *
{
content_type : string,
current_metadata : [string * string],
listeners : [
{
ip : string,
protocol : string,
uri : string
}],
mime_type : string?,
name : string,
peak_listeners : int,
started : float
}]) -> string)?) -> unit

Arguments:

  • name (of type string, which defaults to "icecast.server"): Telnet command namespace
  • port (of type int, which defaults to 8000): Port to listen on
  • password (of type string, which defaults to "hackme"): Source password for authentication
  • dedicated_encoder (of type bool, which defaults to false): When true, create a separate encoder instance for each listener. This uses more resources but ensures each listener gets a clean encoder state.
  • x_forwarded_for_proxy_ips (of type [string?]?, which defaults to null): List of known reverse-proxy IPs. When set, the X-Forwarded-For header is walked right-to-left and the first non-proxy IP is used as the listener IP in stats. Use only when liquidsoap is behind a trusted reverse proxy.
  • x_forwarded_for (of type (( { headers : [string * string], ip : string?, protocol : string, proxy_ips : [string?], uri : string }) -> string?)?, which defaults to null): Advanced: custom callback ({ip, headers, proxy_ips, protocol, uri}) -> string to extract the real listener IP. When set, overrides the default X-Forwarded-For logic. proxy_ips in the record is populated from x_forwarded_for_proxy_ips.
  • format_options (of type ((string) -> [string * string])?, which defaults to null): Callback (string) -> [(string * string)] that returns muxer options for a given container format name. When null, falls back to settings.icecast.server.default_muxer_options.
  • config (of type string?, which defaults to null): Optional path to an icecast XML configuration file
  • serve (of type bool, which defaults to true): When false, disable the status page at / and JSON stats at /status.json.
  • serve_auth (of type (( { body : (?timeout : float) -> string, data : (?timeout : float) -> string, headers : [string * string], http_version : string, method : string, path : string, query : [string * string] }) -> bool)?, which defaults to null): When provided, called with the request and must return true to allow access to the status endpoints.
  • serve_json (of type (([string * { content_type : string, current_metadata : [string * string], listeners : [{ip : string, protocol : string, uri : string}], mime_type : string?, name : string, peak_listeners : int, started : float }]) -> string)?, which defaults to null): When provided, called with the stats list and must return a JSON string for the /status.json endpoint.
  • serve_html (of type (([string * { content_type : string, current_metadata : [string * string], listeners : [{ip : string, protocol : string, uri : string}], mime_type : string?, name : string, peak_listeners : int, started : float }]) -> string)?, which defaults to null): When provided, called with the stats list and must return an HTML string for the / endpoint.

Methods:

  • get_config (of type (string) -> { format : string?, streams : [ { channel_layout? : string, channels? : int, codec : string, field : string, frame_rate? : float?, height? : int, pixel_format? : string, samplerate? : int, type : string, width? : int }]}?):
  • get_source (of type (string) -> source('A)?):
  • mounts (of type () -> [string]):
  • stats (of type () -> [string * { content_type : string, current_metadata : [string * string], listeners : [{ip : string, protocol : string, uri : string}], mime_type : string?, name : string, peak_listeners : int, started : float }]): Returns a list of (mount, stats) pairs. Each stats record contains: name, content_type, started, listeners, peak_listeners, and current_metadata.

Callbacks:

  • on_connect (of type (?synchronous : bool, (( { format : string?, headers : [string * string], mount : string, source : source('A) .{on_disconnect : (synchronous : bool, (() -> unit)) -> unit }, streams : [ { channel_layout? : string, channels? : int, codec : string, field : string, frame_rate? : float?, height? : int, pixel_format? : string, samplerate? : int, type : string, width? : int }] }) -> unit)) -> unit): Called when a source connects. Receives a record with mount, source, format, streams, and headers fields.
  • on_disconnect (of type (?synchronous : bool, (({mount : string}) -> unit)) -> unit): Called when a source disconnects. Receives a record with a mount field.

icecast.server.default_prepare

Default prepare function for icecast.server. Builds a standard fallback source and calls output.harbor.

Type:

('f
.{
burst : int?,
copy_encoder : ('a, options : 'b) -> format('c),
dedicated_encoder : bool,
dumpfile : string?,
format : 'a,
headers : [string * string],
mount : string,
muxer_opts : 'b,
port : int,
source_headers : 'e,
streams : 'd,
timeout : float,
transport : http_transport
}) ->
('g
.{
fallback : source('c)?,
mime_type : string?,
on_listener_connect : (
{
headers : [string * string],
ip : string,
protocol : string,
uri : string
}) -> unit,
on_listener_disconnect : (string) -> unit,
source : source('c)
}) ->
{
clock : clock,
last_metadata : () -> [string * string]?,
shutdown : () -> unit}

Arguments:

  • (unlabeled) (of type 'f .{ burst : int?, copy_encoder : ('a, options : 'b) -> format('c), dedicated_encoder : bool, dumpfile : string?, format : 'a, headers : [string * string], mount : string, muxer_opts : 'b, port : int, source_headers : 'e, streams : 'd, timeout : float, transport : http_transport })

icecast.server.ssl_transport

SSL transport for icecast.server using http.transport.ssl. Overrides TLS transport when both are available.

Type:

(string?, string?) -> http_transport

Arguments:

  • (unlabeled) (of type string?)
  • (unlabeled) (of type string?)

Methods:

  • default_port (of type int): Transport default port
  • name (of type string): Transport name
  • protocol (of type string): Transport protocol

icecast.server.tls_transport

TLS transport for icecast.server using http.transport.tls.

Type:

(string?, string?) -> http_transport

Arguments:

  • (unlabeled) (of type string?)
  • (unlabeled) (of type string?)

Methods:

  • default_port (of type int): Transport default port
  • name (of type string): Transport name
  • protocol (of type string): Transport protocol

icecast.server.x_forwarded_for

Default X-Forwarded-For IP extraction for icecast.server. Walks the X-Forwarded-For header from right to left, skipping any IP present in proxy_ips, and returns the first non-proxy IP. When proxy_ips is empty, returns the rightmost entry unconditionally (trust-all mode).

Type:

('a.{headers : [string * string], ip : string?, proxy_ips : [string?]}) ->
string?

Arguments:

  • (unlabeled) (of type 'a.{headers : [string * string], ip : string?, proxy_ips : [string?]})

settings.icecast.server.default_muxer_options

Default muxer options applied when remuxing incoming streams via copy_encoder, keyed by container format name. Used to enable live/streaming-compatible output for formats that require explicit opt-in.

Type:

() -> [string * [string * string]]

settings.icecast.server.tls_transport

Preferred TLS transport for icecast.server. A pair of (name, factory) where factory takes a certificate path and an optional private key path and returns an HTTP transport.

Type:

() ->
string *
(('a, 'b) -> http_transport
.{default_port : int, name : string, protocol : string})