1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

Added namespace support for aggregating relays

This commit is contained in:
greenbender 2016-02-25 16:42:51 +11:00 committed by Marvin Scholz
parent 85a09dac6a
commit 4ce4616be3
5 changed files with 50 additions and 1 deletions

View File

@ -118,6 +118,7 @@
<port>8001</port>
<username>relay</username>
<password>hackme</password>
<namespace>master1</namespace>
<on-demand>1</on-demand>
</master>
-->

View File

@ -35,6 +35,9 @@ can be setup such that all that needs to be done is configure the slave server w
will also periodically check the master server to see if any new mountpoints have attached and if so will relay those
as well. </p>
<p>This "master-slave" type relay has been extended to support aggregation so that multiple masters can be given
and the slave will "aggregate" all of the mountpoints for those master servers. </p>
<p>The second type of relay is a “single-broadcast” relay. In this case, the slave server is configured with a
server IP, port and mount and only the mountpoint specified is relayed. In order to relay a broadcast stream on
a Shoutcast server, you must use the “single-broadcast” relay and specify a mountpoint of <code>/</code>.</p>
@ -61,6 +64,36 @@ be identical to those on the master server. </p>
</div>
<div class="article">
<h3 id="setting-up-a-master-slave-aggregating-relay">Setting Up a Master-Slave Aggregating Relay</h3>
<p>In order to setup a relay of this type all servers (the one you wish to relay and the one doing the relaying)
need to be Icecast 2 servers. The following configuration snippet is used as an example:</p>
<div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;master-update-interval&gt;</span>120<span class="nt">&lt;/master-update-interval&gt;</span>
<span class="nt">&lt;master&gt;</span>
<span class="nt">&lt;server&gt;</span>192.168.1.11<span class="nt">&lt;/server&gt;</span>
<span class="nt">&lt;port&gt;</span>8001<span class="nt">&lt;/port&gt;</span>
<span class="nt">&lt;namespace&gt;</span>/upstream1<span class="nt">&lt;/namespace&gt;</span>
<span class="nt">&lt;password&gt;</span>hackme<span class="nt">&lt;/password&gt;</span>
<span class="nt">&lt;on-demand&gt;</span>1<span class="nt">&lt;/on-demand&gt;</span>
<span class="nt">&lt;/master&gt;</span>
<span class="nt">&lt;master&gt;</span>
<span class="nt">&lt;server&gt;</span>192.168.1.12<span class="nt">&lt;/server&gt;</span>
<span class="nt">&lt;port&gt;</span>8001<span class="nt">&lt;/port&gt;</span>
<span class="nt">&lt;password&gt;</span>hackme<span class="nt">&lt;/password&gt;</span>
<span class="nt">&lt;/master&gt;</span>
</code></pre></div>
<p>In this example, this configuration is setup in the server which will be doing the relaying (slave server).
The master servers in this case need not be configured (and actually they are unaware of the relaying being performed)
as relays. When the slave server is started, it will connect to each of the master servers located at 192.168.1.11:8001
and 192.168.1.12:8001 and will begin to relay all mountpoints connected to the master servers. Additionally,
every master-update-interval (120 seconds in this case) the slave server will poll the master servers to see if any new
mountpoints have connected, and if so, the slave server will relay those as well. Note that all mountpoints of the master
server at 192.168.1.11:8001 will have the namespace "/upstream1" prepended to it's mountpoints. </p>
</div>
<div class="article">
<h3 id="setting-up-a-single-broadcast-relay">Setting Up a Single-Broadcast Relay</h3>
<p>In this case, the master server need not be an Icecast 2 server. Supported master servers for a single-broadcast

View File

@ -1653,6 +1653,11 @@ static void _parse_master(xmlDocPtr doc,
xmlFree(master->password);
master->password = (char *)xmlNodeListGetString(doc,
node->xmlChildrenNode, 1);
} else if (xmlStrcmp(node->name, XMLSTR("namespace")) == 0) {
if (master->namespace)
xmlFree(master->namespace);
master->namespace = (char *)xmlNodeListGetString(doc,
node->xmlChildrenNode, 1);
} else if (xmlStrcmp(node->name, XMLSTR("on-demand")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
master->on_demand = util_str_to_bool(tmp);

View File

@ -72,6 +72,8 @@ master_server *master_free (master_server *master)
xmlFree (master->username);
if (master->password)
xmlFree (master->password);
if (master->namespace)
xmlFree(master->namespace);
free (master);
return next;
}
@ -688,7 +690,14 @@ static int update_from_master(master_server *master)
}
r->mount = strdup(parsed_uri->path);
r->localmount = strdup(parsed_uri->path);
if (master->namespace)
{
int mountlen = strlen(master->namespace) + strlen(parsed_uri->path) + 1;
r->localmount = malloc(mountlen);
snprintf(r->localmount, mountlen, "%s%s", master->namespace, parsed_uri->path);
} else {
r->localmount = strdup(parsed_uri->path);
}
r->mp3metadata = 1;
r->on_demand = master->on_demand;
r->next = new_relays;

View File

@ -21,6 +21,7 @@ typedef struct _master_server {
char *username;
char *password;
int on_demand;
char *namespace;
struct _master_server *next;
} master_server;