librtmp: Try to parse IPv6 addresses

This should (hopefully) allow URLs of the form rtmp://[abcd::1]/app
master
Palana 2015-02-11 17:17:56 +01:00
parent ce25cf86b6
commit 8a3dd2ef8a
2 changed files with 8 additions and 6 deletions

View File

@ -27,7 +27,7 @@
int RTMP_ParseURL(const char *url, int *protocol, AVal *host, unsigned int *port,
AVal *app)
{
char *p, *end, *col, /* *ques, */ *slash;
char *p, *end, *col, /* *ques, */ *slash, *v6;
RTMP_Log(RTMP_LOGDEBUG, "Parsing...");
@ -83,9 +83,10 @@ parsehost:
}
end = p + strlen(p);
col = strchr(p, ':');
v6 = strchr(p, ']');
// ques = strchr(p, '?');
slash = strchr(p, '/');
col = strchr((v6 && v6 < slash) ? v6 : p, ':');
{
int hostlen;

View File

@ -646,11 +646,12 @@ add_addr_info(struct sockaddr_storage *service, socklen_t *addrlen, AVal *host,
{
char *hostname;
int ret = TRUE;
if (host->av_val[host->av_len])
if (host->av_val[host->av_len] || host->av_val[0] == '[')
{
hostname = malloc(host->av_len+1);
memcpy(hostname, host->av_val, host->av_len);
hostname[host->av_len] = '\0';
int v6 = host->av_val[0] == '[';
hostname = malloc(host->av_len+1 - v6 * 2);
memcpy(hostname, host->av_val + v6, host->av_len - v6 * 2);
hostname[host->av_len - v6 * 2] = '\0';
}
else
{