Listening on IPv6 + IPv4 by default.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4346 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-07-16 14:04:45 +00:00
parent 73bbcebddb
commit 5074246462
2 changed files with 5 additions and 4 deletions

View File

@ -552,7 +552,7 @@ function handleConnection(client) {
} }
let kBacklog = 8; let kBacklog = 8;
let kHost = "0.0.0.0" let kHost = '::';
let socket = new Socket(); let socket = new Socket();
socket.bind(kHost, tildefriends.http_port).then(function(port) { socket.bind(kHost, tildefriends.http_port).then(function(port) {

View File

@ -413,8 +413,9 @@ JSValue _socket_bind(JSContext* context, JSValueConst this_val, int argc, JSValu
socket_resolve_data_t* data = tf_malloc(sizeof(socket_resolve_data_t)); socket_resolve_data_t* data = tf_malloc(sizeof(socket_resolve_data_t));
memset(data, 0, sizeof(*data)); memset(data, 0, sizeof(*data));
struct addrinfo hints = { struct addrinfo hints =
.ai_family = PF_INET, {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM, .ai_socktype = SOCK_STREAM,
.ai_protocol = IPPROTO_TCP, .ai_protocol = IPPROTO_TCP,
.ai_flags = 0, .ai_flags = 0,
@ -602,7 +603,7 @@ JSValue _socket_accept(JSContext* context, JSValueConst this_val, int argc, JSVa
int status = uv_accept((uv_stream_t*)&socket->_socket, (uv_stream_t*)&client->_socket); int status = uv_accept((uv_stream_t*)&socket->_socket, (uv_stream_t*)&client->_socket);
if (status == 0) if (status == 0)
{ {
struct sockaddr_in name = { 0 }; struct sockaddr_storage name = { 0 };
int namelen = (int)sizeof(name); int namelen = (int)sizeof(name);
if (uv_tcp_getpeername(&client->_socket, (struct sockaddr*)&name, &namelen) == 0) if (uv_tcp_getpeername(&client->_socket, (struct sockaddr*)&name, &namelen) == 0)
{ {