mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Added support for shoutcast login protocol (ewww...)
svn path=/trunk/httpp/; revision=4444
This commit is contained in:
parent
f65d885967
commit
b2b618c62f
3
News
3
News
@ -1,3 +1,6 @@
|
|||||||
|
2003-03-09
|
||||||
|
Support for shoutcast source protocol added.
|
||||||
|
|
||||||
2003-03-08
|
2003-03-08
|
||||||
Started implementing generic admin interface. Supports (so far):
|
Started implementing generic admin interface. Supports (so far):
|
||||||
- dynamic configuration of mount fallbacks
|
- dynamic configuration of mount fallbacks
|
||||||
|
@ -424,6 +424,20 @@ static int _check_pass_http(http_parser_t *parser,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _check_pass_icy(http_parser_t *parser, char *correctpass)
|
||||||
|
{
|
||||||
|
char *password;
|
||||||
|
|
||||||
|
password = httpp_getvar(parser, HTTPP_VAR_ICYPASSWORD);
|
||||||
|
if(!password)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (strcmp(password, correctpass))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int _check_pass_ice(http_parser_t *parser, char *correctpass)
|
static int _check_pass_ice(http_parser_t *parser, char *correctpass)
|
||||||
{
|
{
|
||||||
char *password;
|
char *password;
|
||||||
@ -469,6 +483,7 @@ int connection_check_source_pass(http_parser_t *parser, char *mount)
|
|||||||
char *user = "source";
|
char *user = "source";
|
||||||
int ret;
|
int ret;
|
||||||
int ice_login = config->ice_login;
|
int ice_login = config->ice_login;
|
||||||
|
char *protocol;
|
||||||
|
|
||||||
mount_proxy *mountinfo = config->mounts;
|
mount_proxy *mountinfo = config->mounts;
|
||||||
thread_mutex_lock(&(config_locks()->mounts_lock));
|
thread_mutex_lock(&(config_locks()->mounts_lock));
|
||||||
@ -492,6 +507,11 @@ int connection_check_source_pass(http_parser_t *parser, char *mount)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol = httpp_getvar(parser, "HTTP_VAR_PROTOCOL");
|
||||||
|
if(protocol != NULL && !strcmp(protocol, "ICY")) {
|
||||||
|
ret = _check_pass_icy(parser, pass);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ret = _check_pass_http(parser, user, pass);
|
ret = _check_pass_http(parser, user, pass);
|
||||||
if(!ret && ice_login)
|
if(!ret && ice_login)
|
||||||
{
|
{
|
||||||
@ -499,7 +519,7 @@ int connection_check_source_pass(http_parser_t *parser, char *mount)
|
|||||||
if(ret)
|
if(ret)
|
||||||
WARN0("Source is using deprecated icecast login");
|
WARN0("Source is using deprecated icecast login");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,7 +869,12 @@ static void *_handle_connection(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(uri);
|
free(uri);
|
||||||
} else {
|
}
|
||||||
|
else if(httpp_parse_icy(parser, header, strlen(header))) {
|
||||||
|
/* TODO: Map incoming icy connections to /icy_0, etc. */
|
||||||
|
_handle_source_request(con, parser, "/");
|
||||||
|
}
|
||||||
|
else {
|
||||||
ERROR0("HTTP request parsing failed");
|
ERROR0("HTTP request parsing failed");
|
||||||
connection_close(con);
|
connection_close(con);
|
||||||
httpp_destroy(parser);
|
httpp_destroy(parser);
|
||||||
|
@ -270,6 +270,42 @@ static void parse_query(http_parser_t *parser, char *query)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The old shoutcast procotol. Don't look at this, it's really nasty */
|
||||||
|
int httpp_parse_icy(http_parser_t *parser, char *http_data, unsigned long len)
|
||||||
|
{
|
||||||
|
char *data;
|
||||||
|
char *line[MAX_HEADERS];
|
||||||
|
int lines;
|
||||||
|
|
||||||
|
if(http_data == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
data = malloc(len + 1);
|
||||||
|
memcpy(data, http_data, len);
|
||||||
|
data[len] = 0;
|
||||||
|
|
||||||
|
lines = split_headers(data, len, line);
|
||||||
|
|
||||||
|
/* Now, this protocol looks like:
|
||||||
|
* sourcepassword\n
|
||||||
|
* headers: as normal\n"
|
||||||
|
* \n
|
||||||
|
*/
|
||||||
|
|
||||||
|
parser->req_type = httpp_req_source;
|
||||||
|
httpp_setvar(parser, HTTPP_VAR_URI, "/");
|
||||||
|
httpp_setvar(parser, HTTPP_VAR_ICYPASSWORD, line[0]);
|
||||||
|
httpp_setvar(parser, HTTPP_VAR_PROTOCOL, "ICY");
|
||||||
|
/* This protocol is evil */
|
||||||
|
httpp_setvar(parser, HTTPP_VAR_VERSION, "666");
|
||||||
|
|
||||||
|
parse_headers(parser, line, lines);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len)
|
int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len)
|
||||||
{
|
{
|
||||||
char *data, *tmp;
|
char *data, *tmp;
|
||||||
@ -348,8 +384,10 @@ int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
parser->uri = strdup(uri);
|
parser->uri = strdup(uri);
|
||||||
} else
|
} else {
|
||||||
parser->uri = NULL;
|
free(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((version != NULL) && ((tmp = strchr(version, '/')) != NULL)) {
|
if ((version != NULL) && ((tmp = strchr(version, '/')) != NULL)) {
|
||||||
tmp[0] = '\0';
|
tmp[0] = '\0';
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#define HTTPP_VAR_REQ_TYPE "__req_type"
|
#define HTTPP_VAR_REQ_TYPE "__req_type"
|
||||||
#define HTTPP_VAR_ERROR_MESSAGE "__errormessage"
|
#define HTTPP_VAR_ERROR_MESSAGE "__errormessage"
|
||||||
#define HTTPP_VAR_ERROR_CODE "__errorcode"
|
#define HTTPP_VAR_ERROR_CODE "__errorcode"
|
||||||
|
#define HTTPP_VAR_ICYPASSWORD "__icy_password"
|
||||||
|
|
||||||
typedef enum httpp_request_type_tag {
|
typedef enum httpp_request_type_tag {
|
||||||
httpp_req_none, httpp_req_get, httpp_req_post, httpp_req_head,
|
httpp_req_none, httpp_req_get, httpp_req_post, httpp_req_head,
|
||||||
@ -40,6 +41,7 @@ typedef struct http_parser_tag {
|
|||||||
http_parser_t *httpp_create_parser(void);
|
http_parser_t *httpp_create_parser(void);
|
||||||
void httpp_initialize(http_parser_t *parser, http_varlist_t *defaults);
|
void httpp_initialize(http_parser_t *parser, http_varlist_t *defaults);
|
||||||
int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len);
|
int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len);
|
||||||
|
int httpp_parse_icy(http_parser_t *parser, char *http_data, unsigned long len);
|
||||||
int httpp_parse_response(http_parser_t *parser, char *http_data, unsigned long len, char *uri);
|
int httpp_parse_response(http_parser_t *parser, char *http_data, unsigned long len, char *uri);
|
||||||
void httpp_setvar(http_parser_t *parser, char *name, char *value);
|
void httpp_setvar(http_parser_t *parser, char *name, char *value);
|
||||||
char *httpp_getvar(http_parser_t *parser, char *name);
|
char *httpp_getvar(http_parser_t *parser, char *name);
|
||||||
|
Loading…
Reference in New Issue
Block a user