You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
// tcp_proxy.h — TCP прокси: стек lwIP TCP → ETCP → удалённый exit узел |
|
#ifndef TCP_PROXY_H |
|
#define TCP_PROXY_H |
|
|
|
#include <stdint.h> |
|
#include <stddef.h> |
|
#include "../lib/socket_compat.h" |
|
|
|
struct UASYNC; |
|
struct UTUN_INSTANCE; |
|
struct ETCP_CONN; |
|
struct tun_if; |
|
struct ll_queue; |
|
struct ll_entry; |
|
struct memory_pool; |
|
struct tcp_proxy_mapping_config; |
|
struct remote_proxy_ctx; |
|
struct lwip_tcp_ctx; |
|
|
|
struct tcp_pcb; |
|
|
|
struct proxy_conn { |
|
struct proxy_conn* next; |
|
struct tcp_proxy* proxy; |
|
struct tcp_pcb* pcb; |
|
|
|
uint32_t stream_id; |
|
|
|
struct ll_queue* to_lwip; // DATA от exit → lwIP (управление потоком) |
|
|
|
uint8_t tun_closed; // сторона lwIP отправила FIN |
|
uint8_t rem_closed; // exit отправил CLOSE |
|
uint8_t error; // ошибка, немедленная очистка |
|
uint8_t close_sent; // отправили CLOSE/ERROR в exit |
|
uint8_t connected; // CONNECTED(OK) получен от exit |
|
|
|
uint8_t dest_ip[4]; |
|
uint16_t dest_port; |
|
}; |
|
|
|
struct tcp_proxy { |
|
struct UTUN_INSTANCE* inst; |
|
struct UASYNC* ua; |
|
struct tun_if* tun; |
|
struct proxy_conn* conns; |
|
int conn_count; |
|
struct memory_pool* entry_pool; |
|
uint32_t next_stream_id; |
|
uint64_t via_node_id; |
|
struct lwip_tcp_ctx* lwip; |
|
|
|
struct tcp_proxy_mapping_config* mappings; // указатель на конфиг |
|
int mapping_count; |
|
}; |
|
|
|
struct tcp_proxy* tcp_proxy_create(struct UTUN_INSTANCE* inst, struct UASYNC* ua, |
|
const char* tun_name, const char* tun_ip, int mtu, int test_mode, |
|
struct tcp_proxy_mapping_config* mappings, int mapping_count, |
|
uint64_t via_node_id); |
|
void tcp_proxy_destroy(struct tcp_proxy* p); |
|
void tcp_proxy_etcp_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry); |
|
|
|
#endif // TCP_PROXY_H
|
|
|