mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
allow a relay to provide user/pass when connecting
svn path=/icecast/trunk/icecast/; revision=8358
This commit is contained in:
parent
1924d22b91
commit
4066a89c01
@ -208,6 +208,8 @@ certain formats.
|
|||||||
<port>8001</port>
|
<port>8001</port>
|
||||||
<mount>/example.ogg</mount>
|
<mount>/example.ogg</mount>
|
||||||
<local-mount>/different.ogg</local-mount>
|
<local-mount>/different.ogg</local-mount>
|
||||||
|
<username>joe</username>
|
||||||
|
<password>soap</password>
|
||||||
<relay-shoutcast-metadata>0</relay-shoutcast-metadata>
|
<relay-shoutcast-metadata>0</relay-shoutcast-metadata>
|
||||||
</relay>
|
</relay>
|
||||||
</pre>
|
</pre>
|
||||||
@ -279,6 +281,8 @@ A server is configured as a Specific Mountpoint Server relay by specifying a <
|
|||||||
<port>8001</port>
|
<port>8001</port>
|
||||||
<mount>/example.ogg</mount>
|
<mount>/example.ogg</mount>
|
||||||
<local-mount>/different.ogg</local-mount>
|
<local-mount>/different.ogg</local-mount>
|
||||||
|
<username>joe</username>
|
||||||
|
<password>soap</password>
|
||||||
<relay-shoutcast-metadata>0</relay-shoutcast-metadata>
|
<relay-shoutcast-metadata>0</relay-shoutcast-metadata>
|
||||||
</relay>
|
</relay>
|
||||||
</pre>
|
</pre>
|
||||||
@ -300,6 +304,14 @@ The mountpoint located on the remote server. If you are relaying a shoutcast st
|
|||||||
<div class="indentedbox">
|
<div class="indentedbox">
|
||||||
The name to use for the local mountpoint. This is what the mount will be named on the RELAY SERVER.
|
The name to use for the local mountpoint. This is what the mount will be named on the RELAY SERVER.
|
||||||
</div>
|
</div>
|
||||||
|
<h4>username</h4>
|
||||||
|
<div class="indentedbox">
|
||||||
|
The source of the relay may require authentication itself, if so state the username here.
|
||||||
|
</div>
|
||||||
|
<h4>password</h4>
|
||||||
|
<div class="indentedbox">
|
||||||
|
The source of the relay may require authentication itself, if so state the password here.
|
||||||
|
</div>
|
||||||
<h4>relay-shoutcast-metadata</h4>
|
<h4>relay-shoutcast-metadata</h4>
|
||||||
<div class="indentedbox">
|
<div class="indentedbox">
|
||||||
If you are relaying a Shoutcast stream, you need to specify this indicator to also relay the metadata (song titles) that is part of the Shoutcast stream (1=enabled, 0=disabled).
|
If you are relaying a Shoutcast stream, you need to specify this indicator to also relay the metadata (song titles) that is part of the Shoutcast stream (1=enabled, 0=disabled).
|
||||||
|
@ -668,6 +668,14 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node,
|
|||||||
relay->mp3metadata = atoi(tmp);
|
relay->mp3metadata = atoi(tmp);
|
||||||
if(tmp) xmlFree(tmp);
|
if(tmp) xmlFree(tmp);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(node->name, "username") == 0) {
|
||||||
|
relay->username = (char *)xmlNodeListGetString(doc,
|
||||||
|
node->xmlChildrenNode, 1);
|
||||||
|
}
|
||||||
|
else if (strcmp(node->name, "password") == 0) {
|
||||||
|
relay->password = (char *)xmlNodeListGetString(doc,
|
||||||
|
node->xmlChildrenNode, 1);
|
||||||
|
}
|
||||||
} while ((node = node->next));
|
} while ((node = node->next));
|
||||||
if (relay->localmount == NULL)
|
if (relay->localmount == NULL)
|
||||||
relay->localmount = xmlStrdup (relay->mount);
|
relay->localmount = xmlStrdup (relay->mount);
|
||||||
|
36
src/slave.c
36
src/slave.c
@ -74,6 +74,10 @@ relay_server *relay_free (relay_server *relay)
|
|||||||
xmlFree (relay->server);
|
xmlFree (relay->server);
|
||||||
xmlFree (relay->mount);
|
xmlFree (relay->mount);
|
||||||
xmlFree (relay->localmount);
|
xmlFree (relay->localmount);
|
||||||
|
if (relay->username)
|
||||||
|
xmlFree (relay->username);
|
||||||
|
if (relay->password)
|
||||||
|
xmlFree (relay->password);
|
||||||
free (relay);
|
free (relay);
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
@ -88,6 +92,10 @@ relay_server *relay_copy (relay_server *r)
|
|||||||
copy->server = xmlStrdup (r->server);
|
copy->server = xmlStrdup (r->server);
|
||||||
copy->mount = xmlStrdup (r->mount);
|
copy->mount = xmlStrdup (r->mount);
|
||||||
copy->localmount = xmlStrdup (r->localmount);
|
copy->localmount = xmlStrdup (r->localmount);
|
||||||
|
if (r->username)
|
||||||
|
copy->username = xmlStrdup (r->username);
|
||||||
|
if (r->password)
|
||||||
|
copy->password = xmlStrdup (r->password);
|
||||||
copy->port = r->port;
|
copy->port = r->port;
|
||||||
copy->mp3metadata = r->mp3metadata;
|
copy->mp3metadata = r->mp3metadata;
|
||||||
}
|
}
|
||||||
@ -149,6 +157,8 @@ static void *start_relay_stream (void *arg)
|
|||||||
INFO1("Starting relayed source at mountpoint \"%s\"", relay->localmount);
|
INFO1("Starting relayed source at mountpoint \"%s\"", relay->localmount);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
char *auth_header;
|
||||||
|
|
||||||
streamsock = sock_connect_wto (relay->server, relay->port, 30);
|
streamsock = sock_connect_wto (relay->server, relay->port, 30);
|
||||||
if (streamsock == SOCK_ERROR)
|
if (streamsock == SOCK_ERROR)
|
||||||
{
|
{
|
||||||
@ -158,6 +168,26 @@ static void *start_relay_stream (void *arg)
|
|||||||
}
|
}
|
||||||
con = create_connection (streamsock, -1, NULL);
|
con = create_connection (streamsock, -1, NULL);
|
||||||
|
|
||||||
|
if (relay->username && relay->password)
|
||||||
|
{
|
||||||
|
char *esc_authorisation;
|
||||||
|
unsigned len = strlen(relay->username) + strlen(relay->password) + 2;
|
||||||
|
|
||||||
|
auth_header = malloc (len);
|
||||||
|
snprintf (auth_header, len, "%s:%s", relay->username, relay->password);
|
||||||
|
esc_authorisation = util_base64_encode(auth_header);
|
||||||
|
free(auth_header);
|
||||||
|
len = strlen (esc_authorisation) + 24;
|
||||||
|
auth_header = malloc (len);
|
||||||
|
snprintf (auth_header, len,
|
||||||
|
"Authorization: Basic %s\r\n", esc_authorisation);
|
||||||
|
free(esc_authorisation);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auth_header = strdup ("");
|
||||||
|
}
|
||||||
|
|
||||||
/* At this point we may not know if we are relaying an mp3 or vorbis
|
/* At this point we may not know if we are relaying an mp3 or vorbis
|
||||||
* stream, but only send the icy-metadata header if the relay details
|
* stream, but only send the icy-metadata header if the relay details
|
||||||
* state so (the typical case). It's harmless in the vorbis case. If
|
* state so (the typical case). It's harmless in the vorbis case. If
|
||||||
@ -166,8 +196,12 @@ static void *start_relay_stream (void *arg)
|
|||||||
sock_write(streamsock, "GET %s HTTP/1.0\r\n"
|
sock_write(streamsock, "GET %s HTTP/1.0\r\n"
|
||||||
"User-Agent: " ICECAST_VERSION_STRING "\r\n"
|
"User-Agent: " ICECAST_VERSION_STRING "\r\n"
|
||||||
"%s"
|
"%s"
|
||||||
|
"%s"
|
||||||
"\r\n",
|
"\r\n",
|
||||||
relay->mount, relay->mp3metadata?"Icy-MetaData: 1\r\n":"");
|
relay->mount,
|
||||||
|
relay->mp3metadata?"Icy-MetaData: 1\r\n":"",
|
||||||
|
auth_header);
|
||||||
|
free (auth_header);
|
||||||
memset (header, 0, sizeof(header));
|
memset (header, 0, sizeof(header));
|
||||||
if (util_read_header (con->sock, header, 4096, READ_ENTIRE_HEADER) == 0)
|
if (util_read_header (con->sock, header, 4096, READ_ENTIRE_HEADER) == 0)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,8 @@ typedef struct _relay_server {
|
|||||||
char *server;
|
char *server;
|
||||||
int port;
|
int port;
|
||||||
char *mount;
|
char *mount;
|
||||||
|
char *username;
|
||||||
|
char *password;
|
||||||
char *localmount;
|
char *localmount;
|
||||||
struct source_tag *source;
|
struct source_tag *source;
|
||||||
int mp3metadata;
|
int mp3metadata;
|
||||||
|
Loading…
Reference in New Issue
Block a user