1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Feature: Made the set fallback feature accessable via web interface

Not exactly new year, but at least German Unity Day.
This commit is contained in:
Philipp Schafft 2020-10-03 10:28:52 +00:00
parent 4da6d6e243
commit 45818ae8bd
3 changed files with 58 additions and 0 deletions

48
admin/fallbacks.xsl Normal file
View File

@ -0,0 +1,48 @@
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0">
<xsl:output method="html" doctype-system="about:legacy-compat" encoding="UTF-8" />
<!-- Import include files -->
<xsl:include href="includes/page.xsl"/>
<xsl:include href="includes/mountnav.xsl"/>
<xsl:variable name="title">Set fallback</xsl:variable>
<xsl:template name="content">
<div class="section">
<h2><xsl:value-of select="$title" /></h2>
<section class="box">
<h3 class="box_title">Mountpoint <code><xsl:value-of select="@mount" /></code></h3>
<!-- Mount nav -->
<xsl:call-template name="mountnav">
<xsl:with-param name="mount" select="current_source"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="source">
<p>Choose the mountpoint to which you want listeners to fallback to:</p>
<form method="post" action="/admin/fallbacks.xsl">
<label for="fallback" class="hidden">
Set fallback for <code><xsl:value-of select="current_source" /></code> to
</label>
<select name="fallback" id="fallback">
<xsl:for-each select="source">
<option value="{@mount}">
<xsl:value-of select="@mount" />
</option>
</xsl:for-each>
</select>
<input type="hidden" name="mount" value="{current_source}" />
<input type="hidden" name="omode" value="strict" />
&#160;
<input type="submit" value="Set fallback" />
</form>
</xsl:when>
<xsl:otherwise>
<aside class="warning">
<strong>No mounts!</strong>
There are no other mountpoints you could set as fallback.
</aside>
</xsl:otherwise>
</xsl:choose>
</section>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@ -8,6 +8,7 @@
<li><a href="listclients.xsl?mount={$mount}">Clients</a></li>
<li><a href="moveclients.xsl?mount={$mount}">Move listeners</a></li>
<li><a href="updatemetadata.xsl?mount={$mount}">Metadata</a></li>
<li><a href="fallbacks.xsl?mount={$mount}&amp;omode=strict">Set fallback</a></li>
<li class="critical"><a href="killsource.xsl?mount={$mount}">Kill source</a></li>
</ul>
</div>

View File

@ -1058,6 +1058,15 @@ static void command_fallback(client_t *client,
ICECAST_LOG_DEBUG("Got fallback request");
if (client->mode == OMODE_STRICT) {
if (!(COMMAND_OPTIONAL(client, "fallback", fallback))) {
xmlDocPtr doc = admin_build_sourcelist(source->mount);
admin_send_response(doc, client, response, FALLBACK_HTML_REQUEST);
xmlFreeDoc(doc);
return;
}
}
COMMAND_REQUIRE(client, "fallback", fallback);
util_replace_string(&(source->fallback_mount), fallback);