etcp_router: вынести подпись/шифрование в route_crypto, одна функция отправки с флагами
- route_crypto_encode/decode: автономный пред/пост-обработчик пакета (encrypt-then-sign, стандартный Ed25519 вместо sc_stream_sign) - одна функция отправки etcp_route_send/etcp_router_conn_send с bitmask mode - формат доставки: [svc_id][src][dst][rx_flags][payload] (статус подписи/шифрования) - ROUTER_INFLIGHT хранит финальный wire-пакет (чинит потерю подписи при ретрансмите) - дедуп инициализации: router_conn_reset/free_queues - учёт inflight через inflight_q count (seq присваивается на enqueue)
This commit is contained in:
1 parent
7c95ddb09b
commit
2d04bf941b
25 files changed
+549
-592
No files matched your search
@@ -143,7 +143,7 @@ static void raw_read_cb(socket_t sock, void* arg) {
|
||||
memcpy(e->dgram + 12, &icmp_hdr->icmp_seq, 2);
|
||||
if (payload_len > 0) memcpy(e->dgram + ICMP_PROXY_HDR_SIZE, payload, payload_len);
|
||||
e->len = ICMP_PROXY_HDR_SIZE + payload_len;
|
||||
int ret = etcp_route_send(g_icmp_ctx->inst, TOPO_GROUP_UTUN, r->client_node_id, e, 0);
|
||||
int ret = etcp_route_send(g_icmp_ctx->inst, TOPO_GROUP_UTUN, r->client_node_id, e, 0, 0);
|
||||
if (ret != 0) DEBUG_ERROR(DEBUG_CATEGORY_PROXY, "icmp_proxy: etcp_route_send reply failed: %d", ret);
|
||||
else DEBUG_INFO(DEBUG_CATEGORY_PROXY, "icmp_proxy: reply forwarded to client %016llx", (unsigned long long)r->client_node_id);
|
||||
u_free(r);
|
||||
@@ -180,7 +180,7 @@ static void exit_handle_request(struct ETCP_CONN* conn, struct ll_entry* entry)
|
||||
memcpy(e->dgram + 12, &echo_seq, 2);
|
||||
if (payload_len > 0) memcpy(e->dgram + ICMP_PROXY_HDR_SIZE, payload, payload_len);
|
||||
e->len = ICMP_PROXY_HDR_SIZE + payload_len;
|
||||
etcp_route_send(inst, TOPO_GROUP_UTUN, client_node_id, e, 0);
|
||||
etcp_route_send(inst, TOPO_GROUP_UTUN, client_node_id, e, 0, 0);
|
||||
} else queue_entry_free(e);
|
||||
}
|
||||
} else {
|
||||
@@ -244,7 +244,7 @@ int icmp_proxy_send_to_exit(struct UTUN_INSTANCE* inst, uint64_t exit_node_id,
|
||||
memcpy(e->dgram + 12, &echo_seq, 2);
|
||||
if (payload_len > 0) memcpy(e->dgram + ICMP_PROXY_HDR_SIZE, payload, payload_len);
|
||||
e->len = ICMP_PROXY_HDR_SIZE + payload_len;
|
||||
return etcp_route_send(inst, TOPO_GROUP_UTUN, exit_node_id, e, 0);
|
||||
return etcp_route_send(inst, TOPO_GROUP_UTUN, exit_node_id, e, 0, 0);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
@@ -70,7 +70,7 @@ static int send_msg(struct UTUN_INSTANCE* inst, uint64_t group_id, uint64_t dst,
|
||||
queue_dgram_free(e); queue_entry_free(e); return -1;
|
||||
}
|
||||
e->len = (uint16_t)(TCP_PROXY_HDR_SIZE + len);
|
||||
int ret = etcp_route_send(inst, group_id, dst, e, force);
|
||||
int ret = etcp_route_send(inst, group_id, dst, e, force, 0);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_PROXY, "SOCKS send_msg subcmd=%02x sid=%08x len=%zu force=%d → ret=%d",
|
||||
subcmd, sid, len, force, ret);
|
||||
return ret;
|
||||
|
||||
@@ -79,7 +79,7 @@ static int tcp_proxy_client_send_msg(struct UTUN_INSTANCE* inst, uint64_t group_
|
||||
memcpy(e->dgram + 2, &sid, 4);
|
||||
if (len > 0) memcpy(e->dgram + TCP_PROXY_HDR_SIZE, data, len);
|
||||
e->len = TCP_PROXY_HDR_SIZE + len;
|
||||
return etcp_route_send(inst, group_id, dst, e, force);
|
||||
return etcp_route_send(inst, group_id, dst, e, force, 0);
|
||||
}
|
||||
|
||||
static int tcp_proxy_client_send_connect(struct tcp_proxy_client_conn* pc) {
|
||||
|
||||
@@ -65,7 +65,7 @@ static int send_msg(struct UTUN_INSTANCE* inst, uint64_t group_id, uint64_t dst,
|
||||
queue_dgram_free(e); queue_entry_free(e); return -1;
|
||||
}
|
||||
e->len = TCP_PROXY_HDR_SIZE + len;
|
||||
return etcp_route_send(inst, group_id, dst, e, force);
|
||||
return etcp_route_send(inst, group_id, dst, e, force, 0);
|
||||
}
|
||||
|
||||
static void close_retry_cb(void* arg) {
|
||||
|
||||
@@ -64,7 +64,7 @@ static void flow_read_cb(socket_t sock, void* arg) {
|
||||
memcpy(e->dgram + UDP_PROXY_HDR_SIZE, buf, n);
|
||||
e->len = UDP_PROXY_HDR_SIZE + n;
|
||||
|
||||
etcp_route_send(g_udp_ctx->inst, TOPO_GROUP_UTUN, f->client_node_id, e, 0);
|
||||
etcp_route_send(g_udp_ctx->inst, TOPO_GROUP_UTUN, f->client_node_id, e, 0, 0);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
@@ -168,7 +168,7 @@ int udp_proxy_send_to_exit(struct UTUN_INSTANCE* inst, uint64_t exit_node_id,
|
||||
memcpy(e->dgram + 12, &dst_port, 2);
|
||||
if (payload_len > 0) memcpy(e->dgram + UDP_PROXY_HDR_SIZE, payload, payload_len);
|
||||
e->len = UDP_PROXY_HDR_SIZE + payload_len;
|
||||
return etcp_route_send(inst, TOPO_GROUP_UTUN, exit_node_id, e, 0);
|
||||
return etcp_route_send(inst, TOPO_GROUP_UTUN, exit_node_id, e, 0, 0);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
Reference in new issue
Block a user