Skip to content

Commit 8c794ac

Browse files
SteveAyretraviscross
authored andcommitted
FS-3999 --resolve mod_event_socket: add IPv6 support
Signed-off-by: Travis Cross <tc@traviscross.com>
1 parent e8fbaa7 commit 8c794ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/mod/event_handlers/mod_event_socket/mod_event_socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ SWITCH_STANDARD_APP(socket_function)
428428
return;
429429
}
430430

431-
if ((port_name = strchr(host, ':'))) {
431+
if ((port_name = strrchr(host, ':'))) {
432432
*port_name++ = '\0';
433433
port = (switch_port_t) atoi(port_name);
434434
}
@@ -440,12 +440,12 @@ SWITCH_STANDARD_APP(socket_function)
440440

441441
switch_channel_set_variable(channel, "socket_host", host);
442442

443-
if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
443+
if (switch_sockaddr_info_get(&sa, host, SWITCH_UNSPEC, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
444444
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error!\n");
445445
return;
446446
}
447447

448-
if (switch_socket_create(&new_sock, AF_INET, SOCK_STREAM, SWITCH_PROTO_TCP, switch_core_session_get_pool(session))
448+
if (switch_socket_create(&new_sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, switch_core_session_get_pool(session))
449449
!= SWITCH_STATUS_SUCCESS) {
450450
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error!\n");
451451
return;
@@ -2766,7 +2766,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
27662766
config();
27672767

27682768
while (!prefs.done) {
2769-
rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_INET, prefs.port, 0, pool);
2769+
rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_UNSPEC, prefs.port, 0, pool);
27702770
if (rv)
27712771
goto fail;
27722772
rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);

0 commit comments

Comments
 (0)