Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Icecast-Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
94
Issues
94
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiph.Org
Icecast-Server
Commits
38c71f76
Commit
38c71f76
authored
May 28, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature: Allow modules to handle client requests via <resource> tags
parent
f02c23a5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
0 deletions
+49
-0
src/cfgfile.c
src/cfgfile.c
+5
-0
src/cfgfile.h
src/cfgfile.h
+2
-0
src/client.c
src/client.c
+3
-0
src/client.h
src/client.h
+5
-0
src/connection.c
src/connection.c
+34
-0
No files found.
src/cfgfile.c
View file @
38c71f76
...
...
@@ -562,6 +562,8 @@ static void config_clear_resource(resource_t *resource)
xmlFree
(
resource
->
destination
);
xmlFree
(
resource
->
bind_address
);
xmlFree
(
resource
->
vhost
);
xmlFree
(
resource
->
module
);
xmlFree
(
resource
->
handler
);
free
(
resource
);
resource
=
nextresource
;
}
...
...
@@ -1948,6 +1950,9 @@ static void _parse_resource(xmlDocPtr doc,
resource
->
vhost
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"vhost"
));
resource
->
module
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"module"
));
resource
->
handler
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"handler"
));
temp
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"omode"
));
if
(
temp
)
{
resource
->
omode
=
config_str_to_omode
(
temp
);
...
...
src/cfgfile.h
View file @
38c71f76
...
...
@@ -139,6 +139,8 @@ typedef struct _resource {
int
port
;
char
*
bind_address
;
char
*
vhost
;
char
*
module
;
char
*
handler
;
operation_mode
omode
;
unsigned
int
flags
;
struct
_resource
*
next
;
...
...
src/client.c
View file @
38c71f76
...
...
@@ -29,6 +29,7 @@
#include "common/httpp/httpp.h"
#include "global.h"
#include "refobject.h"
#include "cfgfile.h"
#include "connection.h"
#include "refbuf.h"
...
...
@@ -171,6 +172,8 @@ void client_destroy(client_t *client)
if
(
client
->
free_client_data
)
client
->
free_client_data
(
client
);
refobject_unref
(
client
->
handler_module
);
free
(
client
->
handler_function
);
free
(
client
->
username
);
free
(
client
->
password
);
free
(
client
->
role
);
...
...
src/client.h
View file @
38c71f76
...
...
@@ -25,6 +25,7 @@
#include "icecasttypes.h"
#include "errors.h"
#include "refbuf.h"
#include "module.h"
#define CLIENT_DEFAULT_ADMIN_FORMAT ADMIN_FORMAT_TRANSFORMED
...
...
@@ -82,6 +83,10 @@ struct _client_tag {
/* active ACL, set as soon as the client is authenticated */
acl_t
*
acl
;
/* Handler module and function */
module_t
*
handler_module
;
char
*
handler_function
;
/* is client getting intro data */
long
intro_offset
;
...
...
src/connection.c
View file @
38c71f76
...
...
@@ -43,6 +43,7 @@
#include "cfgfile.h"
#include "global.h"
#include "util.h"
#include "refobject.h"
#include "refbuf.h"
#include "client.h"
#include "errors.h"
...
...
@@ -1135,6 +1136,28 @@ static int _handle_resources(client_t *client, char **uri)
}
if
(
resource
->
omode
!=
OMODE_DEFAULT
)
client
->
mode
=
resource
->
omode
;
if
(
resource
->
module
)
{
module_t
*
module
=
module_container_get_module
(
global
.
modulecontainer
,
resource
->
module
);
if
(
module
!=
NULL
)
{
refobject_unref
(
client
->
handler_module
);
client
->
handler_module
=
module
;
}
else
{
ICECAST_LOG_ERROR
(
"Module used in alias not found: %s"
,
resource
->
module
);
}
}
if
(
resource
->
handler
)
{
char
*
func
=
strdup
(
resource
->
handler
);
if
(
func
)
{
free
(
client
->
handler_function
);
client
->
handler_function
=
func
;
}
else
{
ICECAST_LOG_ERROR
(
"Can not allocate memory."
);
}
}
ICECAST_LOG_DEBUG
(
"resource has made %s into %s"
,
*
uri
,
new_uri
);
break
;
}
...
...
@@ -1193,6 +1216,17 @@ static void _handle_authed_client(client_t *client, void *uri, auth_result resul
return
;
}
if
(
client
->
handler_module
&&
client
->
handler_function
)
{
const
module_client_handler_t
*
handler
=
module_get_client_handler
(
client
->
handler_module
,
client
->
handler_function
);
if
(
handler
)
{
handler
->
cb
(
client
->
handler_module
,
client
,
uri
);
free
(
uri
);
return
;
}
else
{
ICECAST_LOG_ERROR
(
"No such handler function in module: %s"
,
client
->
handler_function
);
}
}
switch
(
client
->
parser
->
req_type
)
{
case
httpp_req_source
:
case
httpp_req_put
:
...
...
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