Skip to content

Commit

Permalink
Remove preference of "official servers" & remove fallback for "closes…
Browse files Browse the repository at this point in the history
…t" servers

All servers the client passes to the ICE adapter are to be used.
Especially with Xirsys added to the pool.
  • Loading branch information
Brutus5000 committed Nov 17, 2023
1 parent 2fbfe30 commit 42a6ac6
Showing 1 changed file with 1 addition and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,42 +165,15 @@ private List<IceServer> getViableIceServers() {
return allIceServers;
}

List<IceServer> fafIceServers = allIceServers.stream()
.filter(server -> server.getTurnAddresses().stream()
.anyMatch(transportAddress -> transportAddress.getHostString().contains("faforever.com")))
.toList();
// Try official servers first
List<IceServer> viableIceServers = fafIceServers.stream()
.filter(IceServer::hasAcceptableLatency)
.collect(Collectors.toList());
if (!viableIceServers.isEmpty()) {
log.info("Using official ice servers: {}", viableIceServers.stream().map(it -> "[" + it.getTurnAddresses().stream().map(TransportAddress::toString).collect(Collectors.joining(", ")) + "]").collect(Collectors.joining(", ")));
return viableIceServers;
}

// Try servers with acceptable latency
viableIceServers = allIceServers.stream()
List<IceServer> viableIceServers = allIceServers.stream()
.filter(IceServer::hasAcceptableLatency)
.collect(Collectors.toList());
if (!viableIceServers.isEmpty()) {
log.info("Using all viable ice servers: {}", viableIceServers.stream().map(it -> "[" + it.getTurnAddresses().stream().map(TransportAddress::toString).collect(Collectors.joining(", ")) + "]").collect(Collectors.joining(", ")));
return viableIceServers;
}

// Try the closest server
Optional<IceServer> closestIceServer = allIceServers.stream()
.filter(server -> server.getRoundTripTime().join().isPresent())
.min(Comparator.comparing(server -> server.getRoundTripTime().join().getAsDouble()));
if (closestIceServer.isPresent()) {
log.info("Using closest ice server: {}", closestIceServer.get().getTurnAddresses().stream().map(TransportAddress::toString).collect(Collectors.joining(", ")));
viableIceServers.add(closestIceServer.get());
}

if (!viableIceServers.isEmpty()) {
log.info("Using all reachable ice servers: {}", viableIceServers.stream().map(it -> "[" + it.getTurnAddresses().stream().map(TransportAddress::toString).collect(Collectors.joining(", ")) + "]").collect(Collectors.joining(", ")));
return viableIceServers;
}

log.info("Using all ice servers: {}", allIceServers.stream().map(it -> "[" + it.getTurnAddresses().stream().map(TransportAddress::toString).collect(Collectors.joining(", ")) + "]").collect(Collectors.joining(", ")));
return allIceServers;
}
Expand Down

0 comments on commit 42a6ac6

Please sign in to comment.