security: Make mobile listen on localhost by default. I did not intend to leave it open.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 30m26s

This commit is contained in:
2025-03-08 20:40:03 -05:00
parent 1afdbe6932
commit 973cd53266
6 changed files with 16 additions and 8 deletions

View File

@ -698,7 +698,7 @@ static void _http_on_connection(uv_stream_t* stream, int status)
http->connections[http->connections_count++] = connection;
}
int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cleanup_t* cleanup, void* user_data)
int tf_http_listen(tf_http_t* http, int port, bool local_only, tf_tls_context_t* tls, tf_http_cleanup_t* cleanup, void* user_data)
{
tf_http_listener_t* listener = tf_malloc(sizeof(tf_http_listener_t));
*listener = (tf_http_listener_t) {
@ -724,13 +724,13 @@ int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cle
*/
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = INADDR_ANY },
.sin_addr = { .s_addr = local_only ? INADDR_LOOPBACK : INADDR_ANY },
.sin_port = ntohs(port),
};
#else
struct sockaddr_in6 addr = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ANY_INIT,
.sin6_addr = local_only ? (struct in6_addr)IN6ADDR_LOOPBACK_INIT : (struct in6_addr)IN6ADDR_ANY_INIT,
.sin6_port = ntohs(port),
};
#endif