Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
237eb4f7
Commit
237eb4f7
authored
Nov 21, 2014
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first part of patch to allow kh like admin stats with listener tags inside
svn path=/icecast/trunk/icecast/; revision=19343
parent
1fe898ad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
31 deletions
+67
-31
src/admin.c
src/admin.c
+55
-31
src/admin.h
src/admin.h
+3
-0
src/stats.c
src/stats.c
+9
-0
No files found.
src/admin.c
View file @
237eb4f7
...
...
@@ -704,16 +704,65 @@ static void command_move_clients(client_t *client, source_t *source,
xmlFreeDoc
(
doc
);
}
static
inline
xmlNodePtr
__add_listener
(
client_t
*
client
,
xmlNodePtr
parent
,
time_t
now
)
{
const
char
*
tmp
;
xmlNodePtr
node
;
char
buf
[
22
];
#if 0
xmlSetProp (node, XMLSTR("id"), XMLSTR(buf));
xmlNewChild (node, NULL, XMLSTR("lag"), XMLSTR(buf));
#endif
node
=
xmlNewChild
(
parent
,
NULL
,
XMLSTR
(
"listener"
),
NULL
);
if
(
!
node
)
return
NULL
;
memset
(
buf
,
'\000'
,
sizeof
(
buf
));
snprintf
(
buf
,
sizeof
(
buf
)
-
1
,
"%lu"
,
client
->
con
->
id
);
xmlNewChild
(
node
,
NULL
,
XMLSTR
(
"ID"
),
XMLSTR
(
buf
));
xmlNewChild
(
node
,
NULL
,
XMLSTR
(
"IP"
),
XMLSTR
(
client
->
con
->
ip
));
tmp
=
httpp_getvar
(
client
->
parser
,
"user-agent"
);
if
(
tmp
)
xmlNewChild
(
node
,
NULL
,
XMLSTR
(
"UserAgent"
),
XMLSTR
(
tmp
));
tmp
=
httpp_getvar
(
client
->
parser
,
"referer"
);
if
(
tmp
)
xmlNewChild
(
node
,
NULL
,
XMLSTR
(
"Referer"
),
XMLSTR
(
tmp
));
memset
(
buf
,
'\000'
,
sizeof
(
buf
));
snprintf
(
buf
,
sizeof
(
buf
),
"%lu"
,
(
unsigned
long
)(
now
-
client
->
con
->
con_time
));
xmlNewChild
(
node
,
NULL
,
XMLSTR
(
"Connected"
),
XMLSTR
(
buf
));
if
(
client
->
username
)
xmlNewChild
(
node
,
NULL
,
XMLSTR
(
"username"
),
XMLSTR
(
client
->
username
));
return
node
;
}
void
admin_add_listeners_to_mount
(
source_t
*
source
,
xmlNodePtr
parent
)
{
time_t
now
=
time
(
NULL
);
avl_node
*
client_node
;
avl_tree_rlock
(
source
->
client_tree
);
client_node
=
avl_get_first
(
source
->
client_tree
);
while
(
client_node
)
{
__add_listener
((
client_t
*
)
client_node
->
key
,
parent
,
now
);
client_node
=
avl_get_next
(
client_node
);
}
avl_tree_unlock
(
source
->
client_tree
);
}
static
void
command_show_listeners
(
client_t
*
client
,
source_t
*
source
,
int
response
)
{
xmlDocPtr
doc
;
xmlNodePtr
node
,
srcnode
,
listenernode
;
avl_node
*
client_node
;
client_t
*
current
;
xmlNodePtr
node
,
srcnode
;
char
buf
[
22
];
const
char
*
userAgent
=
NULL
;
time_t
now
=
time
(
NULL
);
doc
=
xmlNewDoc
(
XMLSTR
(
"1.0"
));
node
=
xmlNewDocNode
(
doc
,
NULL
,
XMLSTR
(
"icestats"
),
NULL
);
...
...
@@ -725,33 +774,8 @@ static void command_show_listeners(client_t *client, source_t *source,
snprintf
(
buf
,
sizeof
(
buf
),
"%lu"
,
source
->
listeners
);
xmlNewChild
(
srcnode
,
NULL
,
XMLSTR
(
"Listeners"
),
XMLSTR
(
buf
));
avl_tree_rlock
(
source
->
client_tree
);
client_node
=
avl_get_first
(
source
->
client_tree
);
while
(
client_node
)
{
current
=
(
client_t
*
)
client_node
->
key
;
listenernode
=
xmlNewChild
(
srcnode
,
NULL
,
XMLSTR
(
"listener"
),
NULL
);
xmlNewChild
(
listenernode
,
NULL
,
XMLSTR
(
"IP"
),
XMLSTR
(
current
->
con
->
ip
));
userAgent
=
httpp_getvar
(
current
->
parser
,
"user-agent"
);
if
(
userAgent
)
{
xmlNewChild
(
listenernode
,
NULL
,
XMLSTR
(
"UserAgent"
),
XMLSTR
(
userAgent
));
}
else
{
xmlNewChild
(
listenernode
,
NULL
,
XMLSTR
(
"UserAgent"
),
XMLSTR
(
"Unknown"
));
}
memset
(
buf
,
'\000'
,
sizeof
(
buf
));
snprintf
(
buf
,
sizeof
(
buf
),
"%lu"
,
(
unsigned
long
)(
now
-
current
->
con
->
con_time
));
xmlNewChild
(
listenernode
,
NULL
,
XMLSTR
(
"Connected"
),
XMLSTR
(
buf
));
memset
(
buf
,
'\000'
,
sizeof
(
buf
));
snprintf
(
buf
,
sizeof
(
buf
)
-
1
,
"%lu"
,
current
->
con
->
id
);
xmlNewChild
(
listenernode
,
NULL
,
XMLSTR
(
"ID"
),
XMLSTR
(
buf
));
if
(
current
->
username
)
{
xmlNewChild
(
listenernode
,
NULL
,
XMLSTR
(
"username"
),
XMLSTR
(
current
->
username
));
}
client_node
=
avl_get_next
(
client_node
);
}
admin_add_listeners_to_mount
(
source
,
srcnode
);
avl_tree_unlock
(
source
->
client_tree
);
admin_send_response
(
doc
,
client
,
response
,
LISTCLIENTS_TRANSFORMED_REQUEST
);
xmlFreeDoc
(
doc
);
...
...
src/admin.h
View file @
237eb4f7
...
...
@@ -18,6 +18,7 @@
#include "refbuf.h"
#include "client.h"
#include "source.h"
#define RAW 1
#define TRANSFORMED 2
...
...
@@ -27,4 +28,6 @@ void admin_handle_request(client_t *client, const char *uri);
void
admin_send_response
(
xmlDocPtr
doc
,
client_t
*
client
,
int
response
,
const
char
*
xslt_template
);
void
admin_add_listeners_to_mount
(
source_t
*
source
,
xmlNodePtr
parent
);
#endif
/* __ADMIN_H__ */
src/stats.c
View file @
237eb4f7
...
...
@@ -35,6 +35,7 @@
#include "global.h"
#include "refbuf.h"
#include "client.h"
#include "admin.h"
#include "stats.h"
#include "xslt.h"
#include "util.h"
...
...
@@ -988,6 +989,7 @@ xmlDocPtr stats_get_xml(int show_hidden, const char *show_mount)
{
xmlDocPtr
doc
;
xmlNodePtr
node
;
source_t
*
source
;
doc
=
xmlNewDoc
(
XMLSTR
(
"1.0"
));
node
=
xmlNewDocNode
(
doc
,
NULL
,
XMLSTR
(
"icestats"
),
NULL
);
...
...
@@ -995,6 +997,13 @@ xmlDocPtr stats_get_xml(int show_hidden, const char *show_mount)
node
=
_dump_stats_to_doc
(
node
,
show_mount
,
show_hidden
);
if
(
show_mount
&&
node
)
{
avl_tree_rlock
(
global
.
source_tree
);
source
=
source_find_mount_raw
(
show_mount
);
admin_add_listeners_to_mount
(
source
,
node
);
avl_tree_unlock
(
global
.
source_tree
);
}
return
doc
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment