mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
close report #704, add server-id tag, default stays as the server version string.
svn path=/icecast/trunk/icecast/; revision=13704
This commit is contained in:
parent
47def32074
commit
d327fc8914
@ -337,6 +337,7 @@ ice_config_t *config_get_config_unlocked(void)
|
||||
static void _set_defaults(ice_config_t *configuration)
|
||||
{
|
||||
configuration->location = CONFIG_DEFAULT_LOCATION;
|
||||
configuration->server_id = (char *)xmlCharStrdup (ICECAST_VERSION_STRING);
|
||||
configuration->admin = CONFIG_DEFAULT_ADMIN;
|
||||
configuration->client_limit = CONFIG_DEFAULT_CLIENT_LIMIT;
|
||||
configuration->source_limit = CONFIG_DEFAULT_SOURCE_LIMIT;
|
||||
@ -397,6 +398,9 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node,
|
||||
} else if (strcmp(node->name, "admin") == 0) {
|
||||
if (configuration->admin && configuration->admin != CONFIG_DEFAULT_ADMIN) xmlFree(configuration->admin);
|
||||
configuration->admin = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
} else if (strcmp(node->name, "server-id") == 0) {
|
||||
xmlFree (configuration->server_id);
|
||||
configuration->server_id = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
} else if(strcmp(node->name, "authentication") == 0) {
|
||||
_parse_authentication(doc, node->xmlChildrenNode, configuration);
|
||||
} else if (strcmp(node->name, "source-password") == 0) {
|
||||
|
@ -147,6 +147,7 @@ typedef struct ice_config_tag
|
||||
|
||||
mount_proxy *mounts;
|
||||
|
||||
char *server_id;
|
||||
char *base_dir;
|
||||
char *log_dir;
|
||||
char *pidfile;
|
||||
|
@ -271,6 +271,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
|
||||
int bytes;
|
||||
int bitrate_filtered = 0;
|
||||
avl_node *node;
|
||||
ice_config_t *config;
|
||||
|
||||
remaining = client->refbuf->len;
|
||||
ptr = client->refbuf->data;
|
||||
@ -340,7 +341,9 @@ static int format_prepare_headers (source_t *source, client_t *client)
|
||||
}
|
||||
avl_tree_unlock(source->parser->vars);
|
||||
|
||||
bytes = snprintf (ptr, remaining, "Server: %s\r\n", ICECAST_VERSION_STRING);
|
||||
config = config_get_config();
|
||||
bytes = snprintf (ptr, remaining, "Server: %s\r\n", config->server_id);
|
||||
config_release_config();
|
||||
remaining -= bytes;
|
||||
ptr += bytes;
|
||||
|
||||
|
@ -325,13 +325,16 @@ static int process_vorbis_headers (ogg_state_t *ogg_info, ogg_codec_t *codec)
|
||||
{
|
||||
vorbis_comment vc;
|
||||
ogg_packet header;
|
||||
ice_config_t *config;
|
||||
|
||||
vorbis_comment_init (&vc);
|
||||
if (ogg_info->artist)
|
||||
vorbis_comment_add_tag (&vc, "artist", ogg_info->artist);
|
||||
if (ogg_info->title)
|
||||
vorbis_comment_add_tag (&vc, "title", ogg_info->title);
|
||||
vorbis_comment_add_tag (&vc, "server", ICECAST_VERSION_STRING);
|
||||
config = config_get_config();
|
||||
vorbis_comment_add_tag (&vc, "server", config->server_id);
|
||||
config_release_config();
|
||||
vorbis_commentheader_out (&vc, &header);
|
||||
|
||||
ogg_stream_packetin (&source_vorbis->new_os, &header);
|
||||
|
10
src/slave.c
10
src/slave.c
@ -153,6 +153,8 @@ void slave_shutdown(void)
|
||||
static client_t *open_relay_connection (relay_server *relay)
|
||||
{
|
||||
int redirects = 0;
|
||||
char *server_id = NULL;
|
||||
ice_config_t *config;
|
||||
http_parser_t *parser = NULL;
|
||||
connection_t *con=NULL;
|
||||
char *server = strdup (relay->server);
|
||||
@ -161,6 +163,10 @@ static client_t *open_relay_connection (relay_server *relay)
|
||||
char *auth_header;
|
||||
char header[4096];
|
||||
|
||||
config = config_get_config ();
|
||||
server_id = strdup (config->server_id);
|
||||
config_release_config ();
|
||||
|
||||
/* build any authentication header before connecting */
|
||||
if (relay->username && relay->password)
|
||||
{
|
||||
@ -205,7 +211,7 @@ static client_t *open_relay_connection (relay_server *relay)
|
||||
"%s"
|
||||
"\r\n",
|
||||
mount,
|
||||
ICECAST_VERSION_STRING,
|
||||
server_id,
|
||||
relay->mp3metadata?"Icy-MetaData: 1\r\n":"",
|
||||
auth_header);
|
||||
memset (header, 0, sizeof(header));
|
||||
@ -277,6 +283,7 @@ static client_t *open_relay_connection (relay_server *relay)
|
||||
client_set_queue (client, NULL);
|
||||
free (server);
|
||||
free (mount);
|
||||
free (server_id);
|
||||
free (auth_header);
|
||||
|
||||
return client;
|
||||
@ -286,6 +293,7 @@ static client_t *open_relay_connection (relay_server *relay)
|
||||
/* failed, better clean up */
|
||||
free (server);
|
||||
free (mount);
|
||||
free (server_id);
|
||||
free (auth_header);
|
||||
if (con)
|
||||
connection_close (con);
|
||||
|
@ -589,6 +589,7 @@ void stats_event_time (const char *mount, const char *name)
|
||||
|
||||
void stats_global (ice_config_t *config)
|
||||
{
|
||||
stats_event (NULL, "server_id", config->server_id);
|
||||
stats_event (NULL, "host", config->hostname);
|
||||
stats_event (NULL, "location", config->location);
|
||||
stats_event (NULL, "admin", config->admin);
|
||||
@ -601,7 +602,6 @@ static void *_stats_thread(void *arg)
|
||||
stats_event_t *copy;
|
||||
event_listener_t *listener;
|
||||
|
||||
stats_event (NULL, "server", ICECAST_VERSION_STRING);
|
||||
stats_event_time (NULL, "server_start");
|
||||
|
||||
/* global currently active stats */
|
||||
|
7
src/yp.c
7
src/yp.c
@ -91,6 +91,7 @@ static int yp_running;
|
||||
static time_t now;
|
||||
static thread_type *yp_thread;
|
||||
static volatile unsigned client_limit = 0;
|
||||
static volatile char *server_version = NULL;
|
||||
|
||||
static void *yp_update_thread(void *arg);
|
||||
static void add_yp_info (ypdata_t *yp, void *info, int type);
|
||||
@ -217,6 +218,8 @@ void yp_recheck_config (ice_config_t *config)
|
||||
server = server->next;
|
||||
}
|
||||
client_limit = config->client_limit;
|
||||
free ((char*)server_version);
|
||||
server_version = strdup (config->server_id);
|
||||
/* for each yp url in config, check to see if one exists
|
||||
if not, then add it. */
|
||||
for (i=0 ; i < config->num_yp_directories; i++)
|
||||
@ -242,7 +245,7 @@ void yp_recheck_config (ice_config_t *config)
|
||||
}
|
||||
if (server->touch_interval < 30)
|
||||
server->touch_interval = 30;
|
||||
curl_easy_setopt (server->curl, CURLOPT_USERAGENT, ICECAST_VERSION_STRING);
|
||||
curl_easy_setopt (server->curl, CURLOPT_USERAGENT, server_version);
|
||||
curl_easy_setopt (server->curl, CURLOPT_URL, server->url);
|
||||
curl_easy_setopt (server->curl, CURLOPT_HEADERFUNCTION, handle_returned_header);
|
||||
curl_easy_setopt (server->curl, CURLOPT_WRITEFUNCTION, handle_returned_data);
|
||||
@ -925,6 +928,8 @@ void yp_shutdown (void)
|
||||
if (yp_thread)
|
||||
thread_join (yp_thread);
|
||||
curl_global_cleanup();
|
||||
free ((char*)server_version);
|
||||
server_version = NULL;
|
||||
INFO0 ("YP thread down");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user