Use HTTPS protocol for secure remote URLs.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-04-29 23:51:51 -05:00
parent 1cf0119c29
commit 251bfa3433
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
4 changed files with 30 additions and 4 deletions

View File

@ -373,6 +373,13 @@ class StationMount implements StationMountInterface
return $fe_settings->getPort();
}
public function getAutodjProtocol(): ?string
{
return Adapters::FRONTEND_SHOUTCAST === $this->getAutodjAdapterType()
? self::PROTOCOL_ICY
: null;
}
public function getAutodjUsername(): ?string
{
return '';

View File

@ -9,6 +9,10 @@ interface StationMountInterface
public const FORMAT_AAC = 'aac';
public const FORMAT_OPUS = 'opus';
public const PROTOCOL_ICY = 'icy';
public const PROTOCOL_HTTP = 'http';
public const PROTOCOL_HTTPS = 'https';
public function getEnableAutodj(): bool;
public function getAutodjUsername(): ?string;
@ -23,6 +27,8 @@ interface StationMountInterface
public function getAutodjPort(): ?int;
public function getAutodjProtocol(): ?string;
public function getAutodjMount(): ?string;
public function getAutodjAdapterType(): string;

View File

@ -440,6 +440,18 @@ class StationRemote implements StationMountInterface
$this->source_port = $source_port;
}
public function getAutodjProtocol(): ?string
{
if (Adapters::REMOTE_SHOUTCAST2 === $this->getAutodjAdapterType()) {
return self::PROTOCOL_ICY;
}
$urlScheme = parse_url($this->getUrl(), PHP_URL_SCHEME);
return ('https' === $urlScheme)
? self::PROTOCOL_HTTPS
: self::PROTOCOL_HTTP;
}
public function getAutodjAdapterType(): string
{
return $this->getType();

View File

@ -1037,9 +1037,10 @@ class ConfigWriter implements EventSubscriberInterface
}
$output_params[] = 'password = "' . $password . '"';
$isShoutcastMode = Adapters::REMOTE_ICECAST !== $mount->getAutodjAdapterType();
$protocol = $mount->getAutodjProtocol();
if (!empty($mount->getAutodjMount())) {
if ($isShoutcastMode) {
if ($mount::PROTOCOL_ICY === $protocol) {
$output_params[] = 'icy_id = ' . $id;
} else {
$output_params[] = 'mount = "' . self::cleanUpString($mount->getAutodjMount()) . '"';
@ -1057,8 +1058,8 @@ class ConfigWriter implements EventSubscriberInterface
$output_params[] = 'public = ' . ($mount->getIsPublic() ? 'true' : 'false');
$output_params[] = 'encoding = "' . $charset . '"';
if ($isShoutcastMode) {
$output_params[] = 'protocol="icy"';
if (null !== $protocol) {
$output_params[] = 'protocol="' . $protocol . '"';
}
if (Entity\StationMountInterface::FORMAT_OPUS === $mount->getAutodjFormat()) {