Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tl-stuck'
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Henry committed Feb 9, 2024
2 parents 3ab3154 + 5542dbc commit 4cd1dcf
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions service/OneService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,25 +1172,25 @@ class OneServiceImpl : public OneService
}
}

// If secondary port is not configured to a constant value and we've been offline for a while,
// bind a new secondary port. This is a workaround for a "coma" issue caused by buggy NATs that stop
// working on one port after a while.
if (_secondaryPort == 0) {
if (_node->online()) {
lastOnline = now;
}
if ((now - lastOnline) > ZT_PATH_HEARTBEAT_PERIOD || restarted) {
_ports[1] = _getRandomPort();
// Refresh bindings in case device's interfaces have changed, and also sync routes to update any shadow routes (e.g. shadow default)
if (((now - lastBindRefresh) >= (_node->bondController()->inUse() ? ZT_BINDER_REFRESH_PERIOD / 4 : ZT_BINDER_REFRESH_PERIOD))||restarted) {
// If secondary port is not configured to a constant value and we've been offline for a while,
// bind a new secondary port. This is a workaround for a "coma" issue caused by buggy NATs that stop
// working on one port after a while.
if (_secondaryPort == 0) {
if (_node->online()) {
lastOnline = now;
}
else if (now - lastOnline > (ZT_PEER_PING_PERIOD * 2) || restarted) {
lastOnline = now; // don't keep changing the port before we have a chance to connect
_ports[1] = _getRandomPort();

#if ZT_DEBUG==1
fprintf(stderr, "randomized secondary port. Now it's %d\n", _ports[1]);
fprintf(stderr, "Randomized secondary port. Now it's %d\n", _ports[1]);
#endif
lastOnline = now; // don't keep spamming this branch. online() will be false for a few seconds
}
}
}


// Refresh bindings in case device's interfaces have changed, and also sync routes to update any shadow routes (e.g. shadow default)
if (((now - lastBindRefresh) >= (_node->bondController()->inUse() ? ZT_BINDER_REFRESH_PERIOD / 4 : ZT_BINDER_REFRESH_PERIOD))||restarted) {
unsigned int p[3];
unsigned int pc = 0;
for(int i=0;i<3;++i) {
Expand Down

0 comments on commit 4cd1dcf

Please sign in to comment.