feat(playout): allow harbor ssl configuration
This commit is contained in:
parent
8764feded9
commit
b2fc3a5ecf
17 changed files with 248 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
from pathlib import Path
|
||||
from typing import List, Literal
|
||||
from typing import List, Literal, Optional
|
||||
|
||||
from libretime_shared.config import (
|
||||
BaseConfig,
|
||||
|
@ -7,7 +7,7 @@ from libretime_shared.config import (
|
|||
RabbitMQConfig,
|
||||
StreamConfig,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, root_validator
|
||||
|
||||
CACHE_DIR = Path.cwd() / "scheduler"
|
||||
RECORD_DIR = Path.cwd() / "recorder"
|
||||
|
@ -33,6 +33,23 @@ class LiquidsoapConfig(BaseModel):
|
|||
|
||||
harbor_listen_address: List[str] = ["0.0.0.0"]
|
||||
|
||||
harbor_ssl_certificate: Optional[str] = None
|
||||
harbor_ssl_private_key: Optional[str] = None
|
||||
harbor_ssl_password: Optional[str] = None
|
||||
|
||||
@root_validator
|
||||
@classmethod
|
||||
def _validate_harbor_ssl(cls, values: dict):
|
||||
harbor_ssl_certificate = values.get("harbor_ssl_certificate")
|
||||
harbor_ssl_private_key = values.get("harbor_ssl_private_key")
|
||||
if harbor_ssl_certificate is not None and harbor_ssl_private_key is None:
|
||||
raise ValueError("missing 'harbor_ssl_private_key' value")
|
||||
|
||||
if harbor_ssl_certificate is None and harbor_ssl_private_key is not None:
|
||||
raise ValueError("missing 'harbor_ssl_certificate' value")
|
||||
|
||||
return values
|
||||
|
||||
|
||||
class Config(BaseConfig):
|
||||
general: GeneralConfig
|
||||
|
|
|
@ -120,6 +120,14 @@ def input_main_on_disconnect() update_source_status("master_dj", false) end
|
|||
def input_show_on_connect(header) update_source_status("live_dj", true) end
|
||||
def input_show_on_disconnect() update_source_status("live_dj", false) end
|
||||
|
||||
def make_input_func(secure)
|
||||
if secure then
|
||||
input.harbor.ssl
|
||||
else
|
||||
input.harbor
|
||||
end
|
||||
end
|
||||
|
||||
def make_input_auth_handler(input_name)
|
||||
def auth_handler(user, password)
|
||||
log("user '#{user}' connected", label="#{input_name}_input")
|
||||
|
@ -144,9 +152,10 @@ s = switch(id="switch:blank+schedule",
|
|||
)
|
||||
|
||||
s = if input_show_port != 0 and input_show_mount != "" then
|
||||
input_show_func = make_input_func(input_show_secure)
|
||||
input_show_source =
|
||||
audio_to_stereo(
|
||||
input.harbor(id="harbor:input_show",
|
||||
input_show_func(id="harbor:input_show",
|
||||
input_show_mount,
|
||||
port=input_show_port,
|
||||
auth=make_input_auth_handler("show"),
|
||||
|
@ -166,9 +175,10 @@ else
|
|||
end
|
||||
|
||||
s = if input_main_port != 0 and input_main_mount != "" then
|
||||
input_main_func = make_input_func(input_main_secure)
|
||||
input_main_source =
|
||||
audio_to_stereo(
|
||||
input.harbor(id="harbor:input_main",
|
||||
input_main_func(id="harbor:input_main",
|
||||
input_main_mount,
|
||||
port=input_main_port,
|
||||
auth=make_input_auth_handler("main"),
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
# Inputs
|
||||
input_main_mount = {{ config.stream.inputs.main.mount | quote }}
|
||||
input_main_port = {{ config.stream.inputs.main.port }}
|
||||
input_main_secure = {{ config.stream.inputs.main.secure | string | lower }}
|
||||
input_show_mount = {{ config.stream.inputs.show.mount | quote }}
|
||||
input_show_port = {{ config.stream.inputs.show.port }}
|
||||
input_show_secure = {{ config.stream.inputs.show.secure | string | lower }}
|
||||
|
||||
# Settings
|
||||
{% if paths.log_filepath is defined -%}
|
||||
|
@ -21,6 +23,14 @@ set("server.telnet.port", {{ config.liquidsoap.server_listen_port }})
|
|||
|
||||
set("harbor.bind_addrs", ["{{ config.liquidsoap.harbor_listen_address | join('", "') }}"])
|
||||
|
||||
{% if config.liquidsoap.harbor_ssl_certificate -%}
|
||||
set("harbor.ssl.certificate", "{{ config.liquidsoap.harbor_ssl_certificate }}")
|
||||
set("harbor.ssl.private_key", "{{ config.liquidsoap.harbor_ssl_private_key }}")
|
||||
{% if config.liquidsoap.harbor_ssl_password -%}
|
||||
set("harbor.ssl.password", "{{ config.liquidsoap.harbor_ssl_password }}")
|
||||
{%- endif %}
|
||||
{% endif -%}
|
||||
|
||||
station_name = interactive.string("station_name", {{ info.station_name | quote }})
|
||||
|
||||
message_offline = interactive.string("message_offline", {{ preferences.message_offline | quote }})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue