|
|
|
|
@ -172,6 +172,14 @@ static int tcp_proxy_handle_non_tcp(struct tcp_proxy* p, uint8_t* buf, size_t le
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
|
// Queue callback: автоматически кормит данные из transport_to_uip в lwIP
|
|
|
|
|
// ====================================================================
|
|
|
|
|
static void transport_to_uip_cb(struct ll_queue* q, void* arg) { |
|
|
|
|
proxy_feed_from_transport((struct proxy_conn*)arg); |
|
|
|
|
queue_resume_callback(q); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
|
// Helper: feed data from transport_to_uip queue to lwIP TCP
|
|
|
|
|
// ====================================================================
|
|
|
|
|
@ -222,7 +230,7 @@ static err_t proxy_accept_cb(void *arg, struct tcp_pcb *newpcb, err_t err) {
|
|
|
|
|
tcp_recv(newpcb, proxy_recv_cb); |
|
|
|
|
tcp_sent(newpcb, proxy_sent_cb); |
|
|
|
|
tcp_err(newpcb, proxy_err_cb); |
|
|
|
|
tcp_poll(newpcb, proxy_poll_cb, 0); |
|
|
|
|
tcp_poll(newpcb, proxy_poll_cb, 2); |
|
|
|
|
tcp_nagle_disable(newpcb); |
|
|
|
|
|
|
|
|
|
pc->uip_to_transport = queue_new(p->ua, 0, 0, 0, "uip_to_transport"); |
|
|
|
|
@ -299,7 +307,6 @@ static void proxy_err_cb(void *arg, err_t err) {
|
|
|
|
|
static err_t proxy_poll_cb(void *arg, struct tcp_pcb *pcb) { |
|
|
|
|
struct proxy_conn *pc = (struct proxy_conn *)arg; |
|
|
|
|
if (!pc) return LERR_OK; |
|
|
|
|
proxy_feed_from_transport(pc); |
|
|
|
|
if (pc->closing_tun && pc->closing_rem && pc->pcb) { |
|
|
|
|
struct tcp_pcb *save = pc->pcb; |
|
|
|
|
tcp_arg(save, NULL); pc->pcb = NULL; tcp_close(save); |
|
|
|
|
@ -688,6 +695,7 @@ void tcp_proxy_etcp_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
|
|
|
|
if (data_len > 0) { |
|
|
|
|
struct ll_entry* e = entry_from_data(pc->proxy->entry_pool, entry->dgram + TCP_PROXY_HDR_SIZE, (uint16_t)data_len); |
|
|
|
|
if (e) queue_data_put(pc->transport_to_uip, e); |
|
|
|
|
proxy_feed_from_transport(pc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|