add sockets to gui

This commit is contained in:
Evgeny committed 2026-04-14 21:50:32 +03:00
1 parent cd63f5a1b3
commit ad35bbab15
3 files changed
+24 -1

No files matched your search

+19
View File
@@ -767,6 +767,23 @@ static void send_conn_list(struct control_server* server, struct control_client*
static void send_socket_list(struct control_server* server, struct control_client* client, uint8_t seq_id) {
struct UTUN_INSTANCE* instance = server->instance;
if (!instance || !instance->etcp_sockets) {
uint16_t rsp_size = ETCPMON_SOCKET_LIST_SIZE(0);
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size);
if (!buffer) return;
struct etcpmon_msg_header* hdr = (struct etcpmon_msg_header*)buffer;
etcpmon_build_header(hdr, sizeof(struct etcpmon_rsp_socket_list),
ETCPMON_RSP_SOCKET_LIST, seq_id);
struct etcpmon_rsp_socket_list* rsp = (struct etcpmon_rsp_socket_list*)(buffer + sizeof(*hdr));
rsp->count = 0;
send(client->fd, buffer, rsp_size, 0);
u_free(buffer);
return;
}
uint8_t count = 0;
struct ETCP_SOCKET* sock = instance->etcp_sockets;
while (sock && count < ETCPMON_MAX_CONNECTIONS) {
@@ -774,6 +791,8 @@ static void send_socket_list(struct control_server* server, struct control_clien
sock = sock->next;
}
if (count > ETCPMON_MAX_CONNECTIONS) count = ETCPMON_MAX_CONNECTIONS;
uint16_t rsp_size = ETCPMON_SOCKET_LIST_SIZE(count);
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size);
if (!buffer) {
+1
View File
@@ -476,6 +476,7 @@ static void handle_response(struct etcpmon_client* client, uint8_t msg_type,
struct etcpmon_rsp_socket_list* rsp = (struct etcpmon_rsp_socket_list*)payload;
uint8_t count = rsp->count;
if (count > 16) count = 16; /* Limit to prevent buffer overflow */
if (payload_size < sizeof(*rsp) + count * sizeof(struct etcpmon_socket_info)) break;
if (client->socket_list) {
+4 -1
View File
@@ -955,11 +955,14 @@ static const char* nat_type_to_string(uint8_t nat_type) {
void etcpmon_gui_update_socket_list(struct etcpmon_app* app,
struct etcpmon_socket_info* list,
uint8_t count) {
if (!app || !app->hListSockets) return;
if (!app || !app->hListSockets || !list || count == 0 || count > 32) return;
SendMessage(app->hListSockets, LB_RESETCONTENT, 0, 0);
for (uint8_t i = 0; i < count; i++) {
if (!list[i].ip || list[i].ip[0] == '\0') continue;
if (!list[i].name || list[i].name[0] == '\0') continue;
char display[128];
const char* nat_str = nat_type_to_string(list[i].nat_type);
if (list[i].is_ipv6) {