Skip to content

Commit

Permalink
Add global setting for icecast, set default bind to ivp4 in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jan 18, 2025
1 parent 9c7cfb8 commit 3e6b7c2
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Changed:
- `output.icecast` now re-sends the last metadata when connecting to the
remote server unless explicitly disabled using the `send_last_metadata_on_connect`
option (#3906)
- Add full explicit support for `ipv4` vs. `ipv6` resolution in SRT inputs and outputs,
add global `settings.srt.prefer_address` and `settings.icecast.prefer_address` (#4317)

Fixed:

Expand Down
32 changes: 24 additions & 8 deletions src/core/outputs/icecast2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@

module Http = Liq_http

let conf_icecast =
Dtools.Conf.void ~p:(Configure.conf#plug "icecast") "Icecast configuration"

let conf_prefer_address =
Dtools.Conf.string
~p:(conf_icecast#plug "prefer_address")
~d:"system"
"Set preference for resolving addresses. One of: `\"system\"`, `\"ipv4\"` \
or `\"ipv6\"`."

let error_translator = function
| Cry.Error _ as e -> Some (Cry.string_of_error e)
| _ -> None
Expand Down Expand Up @@ -219,8 +229,9 @@ let proto frame_t =
Lang.nullable_t Lang.string_t,
Some Lang.null,
Some
"Preferred address type when resolving hostnames. One of: `\"ipv4\"` \
or `\"ipv6\"`. Defaults to system default when `null`." );
"Preferred address type when resolving hostnames. One of: \
`\"system\"`, `\"ipv4\"` or `\"ipv6\"`. Defaults to \
`settings.icecast.prefer_address` when `null`." );
( "transport",
Lang.http_transport_base_t,
Some (Lang.base_http_transport Http.unix_transport),
Expand Down Expand Up @@ -435,12 +446,17 @@ class output p =
let transport = e Lang.to_http_transport "transport" in
let prefer_address =
let v = List.assoc "prefer_address" p in
match Lang.to_valued_option Lang.to_string v with
| None -> `System_default
| Some "ipv4" -> `Ipv4
| Some "ipv6" -> `Ipv6
| Some _ ->
raise (Error.Invalid_value (v, "Valid values are: 'ipv4' or 'ipv6'."))
match
Option.value ~default:conf_prefer_address#get
(Lang.to_valued_option Lang.to_string v)
with
| "system" -> `System_default
| "ipv4" -> `Ipv4
| "ipv6" -> `Ipv6
| _ ->
raise
(Error.Invalid_value
(v, "Valid values are: `\"system\"`, `\"ipv4\"` or `\"ipv6\"`."))
in
let transport = (transport :> Cry.transport) in
let transport =
Expand Down
1 change: 1 addition & 0 deletions tests/streams/icecast_last_meta.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
port = 6723
settings.icecast.prefer_address := "ipv4"

s = sine()

Expand Down
1 change: 1 addition & 0 deletions tests/streams/icecast_ssl.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
transport = http.transport.ssl(certificate="./ssl.cert", key="./ssl.key")
settings.icecast.prefer_address := "ipv4"

port = 1443

Expand Down
4 changes: 1 addition & 3 deletions tests/streams/icecast_ssl_tls.liq
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
log.level := 4

# This test is too flakey
test.skip()
settings.icecast.prefer_address := "ipv4"

tls = http.transport.tls(certificate="./ssl.cert", key="./ssl.key")

Expand Down
1 change: 1 addition & 0 deletions tests/streams/icecast_tls.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log.level := 4
settings.icecast.prefer_address := "ipv4"

transport = http.transport.tls(certificate="./ssl.cert", key="./ssl.key")

Expand Down
1 change: 1 addition & 0 deletions tests/streams/icecast_tls_ssl.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log.level := 4
settings.icecast.prefer_address := "ipv4"

tls = http.transport.tls(certificate="./ssl.cert", key="./ssl.key")

Expand Down
1 change: 1 addition & 0 deletions tests/streams/srt_listen_callback.liq
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
log.level.set(4)
port = 8001
settings.srt.prefer_address := "ipv4"

def fn() =
def listen_callback(~hs_version=_, ~peeraddr=_, ~streamid, _) =
Expand Down
1 change: 1 addition & 0 deletions tests/streams/srt_multiple_outputs.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
port = 8002
settings.srt.prefer_address := "ipv4"

def fn() =
connected = ref(0)
Expand Down
1 change: 1 addition & 0 deletions tests/streams/srt_passphrase.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
port = 8003
settings.srt.prefer_address := "ipv4"

def fn() =
output.srt(
Expand Down
1 change: 1 addition & 0 deletions tests/streams/srt_raw_pcm.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log.level := 4
settings.srt.prefer_address := "ipv4"

port = 8004

Expand Down

0 comments on commit 3e6b7c2

Please sign in to comment.