Use Unix Domain Sockets for LS internal connections.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-05-03 14:11:44 -05:00
parent 846be13564
commit 6ecba55950
No known key found for this signature in database
GPG Key ID: 9FC8B9E008872109
2 changed files with 6 additions and 21 deletions

View File

@ -57,19 +57,6 @@ class Liquidsoap extends AbstractBackend
return $event->buildConfiguration();
}
/**
* Returns the internal port used to relay requests and other changes from AzuraCast to LiquidSoap.
*
* @param Entity\Station $station
*
* @return int The port number to use for this station.
*/
public function getTelnetPort(Entity\Station $station): int
{
$settings = $station->getBackendConfig();
return $settings->getTelnetPort() ?? ($this->getStreamPort($station) - 1);
}
/**
* Returns the port used for DJs/Streamers to connect to LiquidSoap for broadcasting.
*
@ -175,12 +162,10 @@ class Liquidsoap extends AbstractBackend
*/
public function command(Entity\Station $station, string $command_str): array
{
$uri = $this->environment->getUriToStations()
->withScheme('tcp')
->withPort($this->getTelnetPort($station));
$socketPath = 'unix://' . $station->getRadioConfigDir() . '/liquidsoap.sock';
$fp = stream_socket_client(
(string)$uri,
$socketPath,
$errno,
$errstr,
20

View File

@ -109,7 +109,7 @@ class ConfigWriter implements EventSubscriberInterface
$configDir = $station->getRadioConfigDir();
$pidfile = $configDir . DIRECTORY_SEPARATOR . 'liquidsoap.pid';
$telnetPort = $this->liquidsoap->getTelnetPort($station);
$socketFile = $configDir . DIRECTORY_SEPARATOR . 'liquidsoap.sock';
$stationTz = self::cleanUpString($station->getTimezone());
@ -123,9 +123,9 @@ class ConfigWriter implements EventSubscriberInterface
settings.server.log.level.set(4)
settings.server.telnet.set(true)
settings.server.telnet.bind_addr.set("127.0.0.1")
settings.server.telnet.port.set(${telnetPort})
settings.server.socket.set(true)
settings.server.socket.permissions.set(0o660)
settings.server.socket.path.set("${socketFile}")
settings.harbor.bind_addrs.set(["0.0.0.0"])