… | |
… | |
69 | } |
69 | } |
70 | |
70 | |
71 | } tcp_si; |
71 | } tcp_si; |
72 | |
72 | |
73 | struct tcp_connection : ev::io { |
73 | struct tcp_connection : ev::io { |
|
|
74 | int tos; |
74 | tstamp last_activity; |
75 | tstamp last_activity; |
75 | const sockinfo si; |
76 | const sockinfo si; |
76 | vpn &v; |
77 | vpn &v; |
77 | bool active; // this connection has been actively established |
78 | bool active; // this connection has been actively established |
78 | enum { ERROR, IDLE, CONNECTING, CONNECTING_PROXY, ESTABLISHED } state; |
79 | enum { ERROR, IDLE, CONNECTING, CONNECTING_PROXY, ESTABLISHED } state; |
… | |
… | |
409 | if (!w_pkt) |
410 | if (!w_pkt) |
410 | { |
411 | { |
411 | // how this maps to the underlying tcp packets we don't know |
412 | // how this maps to the underlying tcp packets we don't know |
412 | // and we don't care. at least we tried ;) |
413 | // and we don't care. at least we tried ;) |
413 | #if defined(SOL_IP) && defined(IP_TOS) |
414 | #if defined(SOL_IP) && defined(IP_TOS) |
|
|
415 | if (tos != this->tos) |
|
|
416 | { |
|
|
417 | this->tos = tos; |
414 | setsockopt (fd, SOL_IP, IP_TOS, &tos, sizeof tos); |
418 | setsockopt (fd, SOL_IP, IP_TOS, &tos, sizeof tos); |
|
|
419 | } |
415 | #endif |
420 | #endif |
416 | |
421 | |
417 | w_pkt = pkt; |
422 | w_pkt = pkt; |
418 | w_ofs = 0; |
423 | w_ofs = 0; |
419 | w_len = pkt->len + 2; // length + size header |
424 | w_len = pkt->len + 2; // length + size header |
… | |
… | |
438 | stop (); |
443 | stop (); |
439 | |
444 | |
440 | if (fd >= 0) |
445 | if (fd >= 0) |
441 | { |
446 | { |
442 | close (fd); |
447 | close (fd); |
|
|
448 | tos = -1; |
443 | fd = -1; |
449 | fd = -1; |
444 | } |
450 | } |
445 | |
451 | |
446 | delete r_pkt; r_pkt = 0; |
452 | delete r_pkt; r_pkt = 0; |
447 | delete w_pkt; w_pkt = 0; |
453 | delete w_pkt; w_pkt = 0; |
448 | #if ENABLE_HTTP_PROXY |
454 | #if ENABLE_HTTP_PROXY |
… | |
… | |
456 | : v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) |
462 | : v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) |
457 | { |
463 | { |
458 | last_activity = ev_now (); |
464 | last_activity = ev_now (); |
459 | r_pkt = 0; |
465 | r_pkt = 0; |
460 | w_pkt = 0; |
466 | w_pkt = 0; |
|
|
467 | tos = -1; |
461 | fd = fd_; |
468 | fd = fd_; |
462 | #if ENABLE_HTTP_PROXY |
469 | #if ENABLE_HTTP_PROXY |
463 | proxy_req = 0; |
470 | proxy_req = 0; |
464 | #endif |
471 | #endif |
465 | |
472 | |