unify TCP_SOCKET into ETCP_SOCKET with is_tcp flag; add local+remote addr to member detail links with arrow display

This commit is contained in:
evgeny committed 2026-08-10 12:06:32 +03:00
1 parent 477b4dfc98
commit 544c77efff
19 files changed
+197 -228

No files matched your search

+3 -3
View File
@@ -60,7 +60,7 @@ struct extra_info {
int type;
int port;
struct ETCP_SOCKET* udp_sock;
struct TCP_SOCKET* tcp_sock;
struct ETCP_SOCKET* tcp_sock;
struct stcp_server* tcp_srv;
struct ETCP_LINK* client_link;
uint64_t create_tb;
@@ -293,11 +293,11 @@ static int add_tcp_pair(struct ETCP_CONN* conn) {
cfg.type = CFG_SERVER_TYPE_PUBLIC; cfg.transport = 1;
memcpy(&cfg.ip, &sin, sizeof(sin));
struct TCP_SOCKET* ts = tcp_socket_add(server_instance, &cfg);
struct ETCP_SOCKET* ts = tcp_socket_add(server_instance, &cfg);
if (!ts) { release_tcp_port(port); return -1; }
struct stcp_link_config scfg = {.ua = ua, .my_keys = &server_instance->my_keys, .inst = server_instance, .listen_family = AF_INET};
struct stcp_server* srv = stcp_server_listen(&scfg, port, tcp_server_on_link, server_instance);
struct stcp_server* srv = stcp_server_listen(&scfg, port, (stcp_server_on_link_cb)tcp_server_on_link, ts);
if (!srv) { tcp_socket_remove(ts); release_tcp_port(port); return -1; }
stcp_server_list_add(server_instance, srv);
+1 -1
View File
@@ -88,7 +88,7 @@ int main(void) {
/* ── Add a TCP socket (simulating Android STCP server) ── */
{
struct TCP_SOCKET* ts = u_calloc(1, sizeof(*ts));
struct ETCP_SOCKET* ts = u_calloc(1, sizeof(*ts));
ts->instance = a;
ts->type = CFG_SERVER_TYPE_PUBLIC;
ts->sock_id = (uint8_t)a->next_socket_id++;
+11 -11
View File
@@ -33,9 +33,9 @@ static void recv_cb(struct ll_queue *q, void *arg) {
queue_resume_callback(q);
}
static void on_srv_link(struct stcp_link *link, void *arg) {
struct stcp_link **out = (struct stcp_link **)arg;
*out = link;
static struct stcp_link *g_on_srv_link = NULL;
static void on_srv_link(struct stcp_link *link, struct ETCP_SOCKET *tcp_sock) {
(void)tcp_sock; g_on_srv_link = link;
}
static void on_cli_ready(struct stcp_link *link, void *arg) {
@@ -48,8 +48,8 @@ static int test1_basic(void) {
struct UASYNC *ua = uasync_create(); TASSERT(ua);
struct stcp_link_config cfg = {.ua = ua, .my_keys = &s_keys, .inst = NULL};
struct stcp_link *srv_link = NULL;
struct stcp_server *ss = stcp_server_listen(&cfg, BASE_PORT + 1, on_srv_link, &srv_link);
g_on_srv_link = NULL;
struct stcp_server *ss = stcp_server_listen(&cfg, BASE_PORT + 1, (stcp_server_on_link_cb)on_srv_link, NULL);
TASSERT(ss);
struct sockaddr_in raddr; memset(&raddr, 0, sizeof(raddr));
@@ -63,8 +63,8 @@ static int test1_basic(void) {
stcp_link_set_on_ready(cli_link, on_cli_ready, &cli_ready);
int ticks = 0;
while ((!srv_link || !cli_ready) && ticks < 5000) { uasync_poll(ua, 10); ticks++; }
TASSERT(srv_link != NULL); TASSERT(cli_ready);
while ((!g_on_srv_link || !cli_ready) && ticks < 5000) { uasync_poll(ua, 10); ticks++; }
TASSERT(g_on_srv_link != NULL); TASSERT(cli_ready);
// Verify send works (no crash, data goes through TCP)
const char *msg = "hello link!";
@@ -81,8 +81,8 @@ static int test2_wrong_key(void) {
struct UASYNC *ua = uasync_create(); TASSERT(ua);
struct stcp_link_config cfg = {.ua = ua, .my_keys = &s_keys, .inst = NULL};
struct stcp_link *srv_link = NULL;
struct stcp_server *ss = stcp_server_listen(&cfg, BASE_PORT + 2, on_srv_link, &srv_link);
g_on_srv_link = NULL;
struct stcp_server *ss = stcp_server_listen(&cfg, BASE_PORT + 2, (stcp_server_on_link_cb)on_srv_link, NULL);
TASSERT(ss);
struct SC_MYKEYS rogue; TASSERT(sc_generate_keypair(&rogue) == SC_OK);
@@ -95,8 +95,8 @@ static int test2_wrong_key(void) {
struct stcp_link *cli_link = stcp_link_connect(&cli_cfg); TASSERT(cli_link);
int ticks = 0;
while (!srv_link && ticks < 2000) { uasync_poll(ua, 10); ticks++; }
TASSERT(!srv_link); // should NOT connect with wrong key
while (!g_on_srv_link && ticks < 2000) { uasync_poll(ua, 10); ticks++; }
TASSERT(!g_on_srv_link); // should NOT connect with wrong key
stcp_link_close(cli_link);
stcp_link_server_destroy(ss);