mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
IPv6 support (for 3.0 release) (#988)
* IPv6 support, part 1. * IPv6 support, part 2. * Some more IPv6 work. * Made functions for address:port paŕsing IPv6-capable. * Fixed type (compile warning). * Fixed formatting. * Reverted option change. * Replaced abort() by proper error handling. * Also retrieving local IPv6 addresses now.
This commit is contained in:
parent
db08f1586c
commit
feaae341b9
20 changed files with 296 additions and 201 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <srs_librtmp.hpp>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
// for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
|
||||
#ifndef _WIN32
|
||||
|
@ -340,16 +341,12 @@ static char *inet_ntop6(const u_char *src, char *dst, socklen_t size);
|
|||
const char* inet_ntop(int af, const void *src, char *dst, socklen_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_ntop4( (unsigned char*)src, (char*)dst, size)); // ****
|
||||
#ifdef AF_INET6
|
||||
#error "IPv6 not supported"
|
||||
//case AF_INET6:
|
||||
// return (char*)(inet_ntop6( (unsigned char*)src, (char*)dst, size)); // ****
|
||||
#endif
|
||||
default:
|
||||
// return (NULL); // ****
|
||||
return 0 ; // ****
|
||||
case AF_INET:
|
||||
return (inet_ntop4( (unsigned char*)src, (char*)dst, size));
|
||||
case AF_INET6:
|
||||
return (char*)(inet_ntop6( (unsigned char*)src, (char*)dst, size));
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
@ -498,7 +495,8 @@ int srs_librtmp_context_resolve_host(Context* context)
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// connect to server:port
|
||||
context->ip = srs_dns_resolve(context->host);
|
||||
int family = AF_UNSPEC;
|
||||
context->ip = srs_dns_resolve(context->host, family);
|
||||
if (context->ip.empty()) {
|
||||
return ERROR_SYSTEM_DNS_RESOLVE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue