… | |
… | |
881 | ? (retry_cnt & 3) + 1 |
881 | ? (retry_cnt & 3) + 1 |
882 | : 1 << (retry_cnt >> 2)); |
882 | : 1 << (retry_cnt >> 2)); |
883 | |
883 | |
884 | reset_si (); |
884 | reset_si (); |
885 | |
885 | |
886 | bool slow = si.prot & PROT_SLOW; |
886 | bool slow = (si.prot & PROT_SLOW) || (conf->low_power || THISNODE->low_power); |
887 | |
887 | |
888 | if (si.prot && !si.host && vpn->can_direct (THISNODE, conf)) |
888 | if (si.prot && !si.host && vpn->can_direct (THISNODE, conf)) |
889 | { |
889 | { |
890 | /*TODO*/ /* start the timer so we don't recurse endlessly */ |
890 | /*TODO*/ /* start the timer so we don't recurse endlessly */ |
891 | w.start (1); |
891 | w.start (1); |
… | |
… | |
901 | |
901 | |
902 | slow = slow || (dsi.prot & PROT_SLOW); |
902 | slow = slow || (dsi.prot & PROT_SLOW); |
903 | |
903 | |
904 | if (dsi.valid () && auth_rate_limiter.can (dsi)) |
904 | if (dsi.valid () && auth_rate_limiter.can (dsi)) |
905 | { |
905 | { |
906 | if (retry_cnt < 4) |
906 | // use ping after the first few retries |
|
|
907 | // TODO: on rekeys, the other node might not interpret ping correctly, |
|
|
908 | // TODO: as it will still have a valid connection |
|
|
909 | if (retry_cnt < 4 && (!conf->low_power || THISNODE->low_power)) |
907 | send_auth_request (dsi, true); |
910 | send_auth_request (dsi, true); |
908 | else |
911 | else |
909 | send_ping (dsi, 0); |
912 | send_ping (dsi, 0); |
910 | } |
913 | } |
911 | } |
914 | } |
912 | |
915 | |
913 | retry_int *= slow ? 8. : 0.9; |
916 | retry_int *= slow ? 4. : 0.9; |
914 | |
917 | |
915 | if (retry_int < conf->max_retry) |
918 | if (retry_int < conf->max_retry) |
916 | retry_cnt++; |
919 | retry_cnt++; |
917 | else |
920 | else |
918 | retry_int = conf->max_retry; |
921 | retry_int = conf->max_retry; |
… | |
… | |
993 | |
996 | |
994 | void |
997 | void |
995 | connection::post_inject_queue () |
998 | connection::post_inject_queue () |
996 | { |
999 | { |
997 | // force a connection every now and when when packets are sent (max 1/s) |
1000 | // force a connection every now and when when packets are sent (max 1/s) |
998 | if (ev_now () - last_establish_attempt >= 0.95) // arbitrary |
1001 | if (ev_now () - last_establish_attempt >= (conf->low_power || THISNODE->low_power ? 2.95 : 0.95)) // arbitrary |
999 | establish_connection.stop (); |
1002 | establish_connection.stop (); |
1000 | |
1003 | |
1001 | establish_connection (); |
1004 | establish_connection (); |
1002 | } |
1005 | } |
1003 | |
1006 | |