#5047 -- Extend to include Shoutcast too.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-02-10 15:28:00 -06:00
parent df46e7e030
commit 2001cd3aef
No known key found for this signature in database
GPG Key ID: 9FC8B9E008872109
4 changed files with 19 additions and 18 deletions

View File

@ -111,7 +111,7 @@
</template>
</b-wrapped-form-group>
<b-wrapped-form-group v-if="!isShoutcastFrontend" id="edit_form_frontend_banned_user_agents"
<b-wrapped-form-group id="edit_form_frontend_banned_user_agents"
:field="form.frontend_config.banned_user_agents" input-type="textarea"
:input-attrs="{class: 'text-preformatted'}" advanced>
<template #label="{lang}">

View File

@ -179,6 +179,23 @@ abstract class AbstractFrontend extends AbstractAdapter
return false;
}
protected function writeUserAgentBansFile(Entity\Station $station): string
{
$bannedUserAgents = array_filter(
array_map(
'trim',
explode("\n", $station->getFrontendConfig()->getBannedUserAgents() ?? '')
)
);
$configDir = $station->getRadioConfigDir();
$bansFile = $configDir . '/user_agent_bans.txt';
file_put_contents($bansFile, implode("\n", $bannedUserAgents));
return $bansFile;
}
protected function writeIpBansFile(Entity\Station $station): string
{
$ips = [];

View File

@ -293,23 +293,6 @@ class Icecast extends AbstractFrontend
return substr($configString, strpos($configString, "\n") + 1);
}
protected function writeUserAgentBansFile(Entity\Station $station): string
{
$bannedUserAgents = array_filter(
array_map(
'trim',
explode("\n", $station->getFrontendConfig()->getBannedUserAgents() ?? '')
)
);
$configDir = $station->getRadioConfigDir();
$bansFile = $configDir . '/user_agent_bans.txt';
file_put_contents($bansFile, implode("\n", $bannedUserAgents));
return $bansFile;
}
public function getCommand(Entity\Station $station): ?string
{
if ($binary = $this->getBinary()) {

View File

@ -123,6 +123,7 @@ class Shoutcast extends AbstractFrontend
'logfile' => $configPath . '/sc_serv.log',
'w3clog' => $configPath . '/sc_w3c.log',
'banfile' => $this->writeIpBansFile($station),
'agentfile' => $this->writeUserAgentBansFile($station),
'ripfile' => $configPath . '/sc_serv.rip',
'maxuser' => $frontendConfig->getMaxListeners() ?? 250,
'portbase' => $frontendConfig->getPort(),