Closes #112 - Return to using harbor to allow both IC and SC2 to share streamer config and update streamer pages accordingly.

This commit is contained in:
Buster Silver 2017-04-22 20:48:19 -05:00
parent 579ca54ace
commit 6236781fc8
10 changed files with 73 additions and 54 deletions

View File

@ -7,7 +7,7 @@ class StreamersController extends BaseController
{
protected function preDispatch()
{
if (!$this->frontend->supportsStreamers()) {
if (!$this->backend->supportsStreamers()) {
throw new \App\Exception(_('This feature is not currently supported on this station.'));
}
@ -38,6 +38,8 @@ class StreamersController extends BaseController
}
$this->view->server_url = $this->em->getRepository('Entity\Settings')->getSetting('base_url', '');
$this->view->stream_port = $this->backend->getStreamPort();
$this->view->streamers = $this->station->streamers;
}

View File

@ -24,7 +24,7 @@
<li><a href="<?=$url->named('stations:mounts:index', ['station' => $station->id]) ?>"><i class="zmdi zmdi-portable-wifi"></i> <?=_('Mount Points') ?></a></li>
<?php endif; ?>
<?php if ($acl->isAllowed('manage station streamers', $station->id) && $frontend->supportsStreamers()): ?>
<?php if ($acl->isAllowed('manage station streamers', $station->id) && $backend->supportsStreamers()): ?>
<li><a href="<?=$url->named('stations:streamers:index', ['station' => $station->id]) ?>"><i class="zmdi zmdi-account"></i> <?=_('Streamer/DJ Accounts') ?></a></li>
<?php endif; ?>

View File

@ -47,41 +47,32 @@
<h2><?=_('Connection Information') ?></h2>
</div>
<div class="card-body card-padding">
<?php
$frontend_type = $station->frontend_type;
$frontend_info = (array)$station->frontend_config;
<h4><?=_('IceCast Clients') ?></h4>
<dl>
<dt><?=_('Server') ?>:</dt>
<dd><?=$server_url ?></dd>
if ($frontend_type == 'icecast'):
?>
<h4><?=_('IceCast Clients') ?></h4>
<dl>
<dt><?=_('Server') ?>:</dt>
<dd><?=$server_url ?></dd>
<dt><?=_('Port') ?>:</dt>
<dd><?=$stream_port ?></dd>
<dt><?=_('Port') ?>:</dt>
<dd><?=(int)$frontend_info['port'] ?></dd>
<dt><?=_('Mount Name') ?>:</dt>
<dd>/</dd>
</dl>
<dt><?=_('Mount Name') ?>:</dt>
<dd>/radio.mp3</dd>
</dl>
<h4><?=_('ShoutCast v1 Clients') ?></h4>
<dl>
<dt><?=_('Server') ?>:</dt>
<dd><?=$server_url ?></dd>
<h4><?=_('ShoutCast 1.x Legacy Clients') ?></h4>
<dl>
<dt><?=_('Server') ?>:</dt>
<dd><?=$server_url ?></dd>
<dt><?=_('Port') ?>:</dt>
<dd><?=($stream_port + 1) ?></dd>
<dt><?=_('Port') ?>:</dt>
<dd><?=(int)$frontend_info['port']+1 ?></dd>
<dt><?=('Username') ?>:</dt>
<dd>(Leave blank)</dd>
<dt><?=_('Password') ?>:</dt>
<dd><?=$frontend_info['streamer_pw'] ?></dd>
</dl>
<?php
endif;
?>
<dt><?=_('Password') ?>:</dt>
<dd>
dj_username:dj_password<br>
<small><?=_('(DJ username and password separated by a colon)') ?></small>
</dd>
</dl>
</div>
</div>
</div>

View File

@ -57,6 +57,11 @@ class StreamerAuth extends \App\Console\Command\CommandAbstract
return $this->_return($output, 'false');
}
$fe_config = (array)$station->frontend_config;
if (!empty($fe_config['source_pw']) && strcmp($fe_config['source_pw'], $pass) === 0) {
return $this->_return($output, 'true');
}
if ($this->di['em']->getRepository(StationStreamer::class)->authenticate($station, $user, $pass)) {
return $this->_return($output, 'true');
} else {

View File

@ -17,6 +17,18 @@ abstract class BackendAbstract extends \AzuraCast\Radio\AdapterAbstract
return $this->supports_requests;
}
protected $supports_streamers = true;
public function supportsStreamers()
{
return $this->supports_streamers;
}
public function getStreamPort()
{
return null;
}
public function log($message, $class = 'info')
{
if (!empty(trim($message))) {

View File

@ -33,18 +33,10 @@ class LiquidSoap extends BackendAbstract
$ls_config[] = 'set("server.telnet.port", ' . $this->_getTelnetPort() . ')';
$ls_config[] = 'set("server.telnet.reverse_dns",false)';
$ls_config[] = '';
$ls_config[] = 'set("harbor.bind_addr","0.0.0.0")';
$ls_config[] = 'set("harbor.reverse_dns",false)';
/*
// Set up harbor auth script.
$ls_config[] = '# DJ Authentication';
$ls_config[] = 'def dj_auth(user,password) =';
$ls_config[] = ' ret = get_process_lines("/usr/bin/php '.APP_INCLUDE_ROOT.'/util/cli.php streamer:auth '.$this->station->id.' #{user} #{password}")';
$ls_config[] = ' ret = list.hd(ret)';
$ls_config[] = ' bool_of_string(ret)';
$ls_config[] = 'end';
$ls_config[] = '';
*/
// Clear out existing playlists directory.
$current_playlists = array_diff(scandir($playlist_path), ['..', '.']);
@ -158,12 +150,28 @@ class LiquidSoap extends BackendAbstract
}
}
/*
// Add harbor live.
$ls_config[] = '# Harbor Live DJs';
$ls_config[] = 'live = input.harbor("/", port='.$this->_getHarborPort().', user="shoutcast", auth=dj_auth, icy=true)';
// Set up harbor auth script.
$ls_config[] = '# DJ Authentication';
$ls_config[] = 'def dj_auth(user,password) =';
$ls_config[] = ' ret = get_process_lines("/usr/bin/php '.APP_INCLUDE_ROOT.'/util/cli.php streamer:auth '.$this->station->id.' #{user} #{password}")';
$ls_config[] = ' ret = list.hd(ret)';
$ls_config[] = ' bool_of_string(ret)';
$ls_config[] = 'end';
$ls_config[] = '';
// Add harbor live.
$harbor_params = [
'"/"',
'port='.$this->getStreamPort(),
'user="shoutcast"',
'auth=dj_auth',
'icy=true',
];
$ls_config[] = '# Harbor Live DJs';
$ls_config[] = 'live = input.harbor('.implode(', ', $harbor_params).')';
$ls_config[] = 'radio = fallback(track_sensitive = false, [live, radio])';
$ls_config[] = '';
*/
// Add fallback error file.
// $error_song_path = APP_INCLUDE_ROOT.'/resources/error.mp3';
@ -359,6 +367,11 @@ class LiquidSoap extends BackendAbstract
return $response;
}
public function getStreamPort()
{
return (8000 + (($this->station->id - 1) * 10) + 5);
}
protected function _getTelnetPort()
{
return (8500 + (($this->station->id - 1) * 10));

View File

@ -7,6 +7,8 @@ class None extends BackendAbstract
protected $supports_requests = false;
protected $supports_streamers = false;
public function read()
{
}

View File

@ -16,12 +16,7 @@ abstract class FrontendAbstract extends \AzuraCast\Radio\AdapterAbstract
{
}
protected $supports_streamers = true;
public function supportsStreamers()
{
return $this->supports_streamers;
}
public function getProgramName()
{

View File

@ -7,8 +7,6 @@ class Remote extends FrontendAbstract
{
protected $supports_mounts = false;
protected $supports_streamers = false;
/* Process a nowplaying record. */
protected function _getNowPlaying(&$np)
{

View File

@ -193,6 +193,7 @@ class ShoutCast2 extends FrontendAbstract
'ripfile' => $config_path . '/sc_serv.rip',
'maxuser' => 500,
'portbase' => $this->_getRadioPort(),
'requirestreamconfigs' => 1,
];
return $defaults;