… | |
… | |
104 | ~tcp_connection (); |
104 | ~tcp_connection (); |
105 | }; |
105 | }; |
106 | |
106 | |
107 | void tcp_si_map::cleaner_cb (ev::timer &w, int revents) |
107 | void tcp_si_map::cleaner_cb (ev::timer &w, int revents) |
108 | { |
108 | { |
109 | tstamp to = ev::ev_now () - ::conf.keepalive - 30 - 60; |
109 | tstamp to = ev_now () - ::conf.keepalive - 30 - 60; |
110 | |
110 | |
111 | for (iterator i = begin (); i != end(); ) |
111 | for (iterator i = begin (); i != end(); ) |
112 | if (i->second->last_activity >= to) |
112 | if (i->second->last_activity >= to) |
113 | ++i; |
113 | ++i; |
114 | else |
114 | else |
… | |
… | |
201 | } |
201 | } |
202 | |
202 | |
203 | void |
203 | void |
204 | tcp_connection::tcpv4_ev (ev::io &w, int revents) |
204 | tcp_connection::tcpv4_ev (ev::io &w, int revents) |
205 | { |
205 | { |
206 | last_activity = ev::ev_now (); |
206 | last_activity = ev_now (); |
207 | |
207 | |
208 | if (revents & EV_WRITE) |
208 | if (revents & EV_WRITE) |
209 | { |
209 | { |
210 | if (state == CONNECTING) |
210 | if (state == CONNECTING) |
211 | { |
211 | { |
… | |
… | |
346 | } |
346 | } |
347 | |
347 | |
348 | bool |
348 | bool |
349 | tcp_connection::send_packet (vpn_packet *pkt, int tos) |
349 | tcp_connection::send_packet (vpn_packet *pkt, int tos) |
350 | { |
350 | { |
351 | last_activity = ev::ev_now (); |
351 | last_activity = ev_now (); |
352 | |
352 | |
353 | if (state == IDLE) |
353 | if (state == IDLE) |
354 | { |
354 | { |
355 | // woaw, the first lost packet ;) |
355 | // woaw, the first lost packet ;) |
356 | fd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); |
356 | fd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); |
… | |
… | |
453 | } |
453 | } |
454 | |
454 | |
455 | tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_) |
455 | tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_) |
456 | : v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) |
456 | : v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) |
457 | { |
457 | { |
458 | last_activity = ev::ev_now (); |
458 | last_activity = ev_now (); |
459 | r_pkt = 0; |
459 | r_pkt = 0; |
460 | w_pkt = 0; |
460 | w_pkt = 0; |
461 | fd = fd_; |
461 | fd = fd_; |
462 | #if ENABLE_HTTP_PROXY |
462 | #if ENABLE_HTTP_PROXY |
463 | proxy_req = 0; |
463 | proxy_req = 0; |