Compare commits

..

No commits in common. "efe2b6cbd901aabb11d53b14498d0d2232cb36a7" and "cf187ee46b06439bda8b850756c452ef6f302c17" have entirely different histories.

6 changed files with 11 additions and 27 deletions

View File

@ -882,10 +882,6 @@ format:
@clang-format -i $(wildcard src/*.c src/*.h src/*.m)
.PHONY: format
prettier:
@npm run prettier
.PHONY: prettier
docs:
@doxygen
.PHONY: docs

View File

@ -578,7 +578,6 @@ async function getProcessBlob(blobId, key, options) {
imports.ssb = Object.fromEntries(
Object.keys(ssb).map((key) => [key, ssb[key].bind(ssb)])
);
imports.ssb.port = tildefriends.ssb_port;
imports.ssb.createIdentity = function () {
if (
process.credentials &&

View File

@ -2824,19 +2824,19 @@ static void _tf_ssb_broadcast_timer(uv_timer_t* timer)
}
}
int tf_ssb_server_open(tf_ssb_t* ssb, int port)
void tf_ssb_server_open(tf_ssb_t* ssb, int port)
{
if (ssb->server.data)
{
tf_printf("Already listening.\n");
return 0;
return;
}
ssb->server.data = ssb;
if (uv_tcp_init(ssb->loop, &ssb->server) != 0)
{
tf_printf("uv_tcp_init failed\n");
return 0;
return;
}
struct sockaddr_in addr = { 0 };
@ -2847,7 +2847,7 @@ int tf_ssb_server_open(tf_ssb_t* ssb, int port)
if (status != 0)
{
tf_printf("%s:%d: uv_tcp_bind failed: %s\n", __FILE__, __LINE__, uv_strerror(status));
return 0;
return;
}
status = uv_listen((uv_stream_t*)&ssb->server, SOMAXCONN, _tf_ssb_on_connection);
@ -2855,14 +2855,8 @@ int tf_ssb_server_open(tf_ssb_t* ssb, int port)
{
tf_printf("uv_listen failed: %s\n", uv_strerror(status));
/* TODO: cleanup */
return 0;
return;
}
struct sockaddr_storage name = { 0 };
int size = (int)sizeof(name);
status = uv_tcp_getsockname(&ssb->server, (struct sockaddr*)&name, &size);
int assigned_port = ntohs(((struct sockaddr_in*)&name)->sin_port);
return status == 0 ? assigned_port : 0;
}
void tf_ssb_server_close(tf_ssb_t* ssb)

View File

@ -316,9 +316,8 @@ void tf_ssb_connect_str(tf_ssb_t* ssb, const char* address);
** Begin listening for SHS connections on the given port.
** @param ssb The SSB instance.
** @param port The port number.
** @return The assigned port on success or 0 on failure.
*/
int tf_ssb_server_open(tf_ssb_t* ssb, int port);
void tf_ssb_server_open(tf_ssb_t* ssb, int port);
/**
** Stop listening for SHS connections.

View File

@ -30,8 +30,7 @@ static int64_t _get_global_setting_int64(tf_ssb_t* ssb, const char* name, int64_
{
if (sqlite3_bind_text(statement, 1, name, -1, NULL) == SQLITE_OK)
{
if (sqlite3_step(statement) == SQLITE_ROW &&
sqlite3_column_type(statement, 0) != SQLITE_NULL)
if (sqlite3_step(statement) == SQLITE_ROW)
{
result = sqlite3_column_int64(statement, 0);
}

View File

@ -1694,6 +1694,9 @@ void tf_task_activate(tf_task_t* task)
JS_FreeAtom(context, atom);
JSValue tildefriends = JS_NewObject(context);
JS_SetPropertyStr(context, tildefriends, "ssb_port", JS_NewInt32(context, task->_ssb_port));
JS_SetPropertyStr(context, tildefriends, "http_port", JS_NewInt32(context, task->_http_port));
JS_SetPropertyStr(context, tildefriends, "https_port", JS_NewInt32(context, task->_https_port));
JSValue args = JS_NewObject(context);
JS_SetPropertyStr(context, tildefriends, "args", args);
if (task->_args)
@ -1746,19 +1749,13 @@ void tf_task_activate(tf_task_t* task)
tf_ssb_register(context, task->_ssb);
tf_ssb_set_hitch_callback(task->_ssb, _tf_task_record_hitch, task);
int actual_ssb_port = task->_ssb_port;
if (task->_ssb_port)
{
tf_ssb_broadcast_listener_start(task->_ssb, false);
tf_ssb_broadcast_sender_start(task->_ssb);
actual_ssb_port = tf_ssb_server_open(task->_ssb, task->_ssb_port);
tf_ssb_server_open(task->_ssb, task->_ssb_port);
}
JS_SetPropertyStr(context, tildefriends, "ssb_port", JS_NewInt32(context, actual_ssb_port));
JS_SetPropertyStr(context, tildefriends, "http_port", JS_NewInt32(context, task->_http_port));
JS_SetPropertyStr(context, tildefriends, "https_port", JS_NewInt32(context, task->_https_port));
JS_SetPropertyStr(context, global, "getStats", JS_NewCFunction(context, _tf_task_getStats, "getStats", 0));
}
else