Skip to content

Commit

Permalink
Shuffle the endpoint list from SteamDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
azuisleet committed Jul 1, 2021
1 parent 9e5f746 commit 90c2847
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SteamKit2/SteamKit2/Steam/Discovery/SmartCMServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ private async Task ResolveServerList()
if ( endpointList.Count == 0 && configuration.AllowDirectoryFetch )
{
DebugWrite( "Server list provider had no entries, will query SteamDirectory" );
endpointList = await SteamDirectory.LoadAsync( configuration ).ConfigureAwait( false );
var directoryEndpoints = await SteamDirectory.LoadAsync( configuration ).ConfigureAwait( false );

// The endpoint list provided by SteamDirectory is ordered. Shuffle this list so we try different CMs instead of the same CM sequentially.
var random = new Random();
endpointList = directoryEndpoints.OrderBy( a => random.Next() ).ToList();
}

if ( endpointList.Count == 0 && configuration.AllowDirectoryFetch )
Expand Down

3 comments on commit 90c2847

@xPaw
Copy link
Member

@xPaw xPaw commented on 90c2847 Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the servers ordered by best/closest ones? While I agree that it may give dead servers at the top, this doesn't seem like a particularly good fix. SteamKit already has a mechanism for marking bad servers.

@azuisleet
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The good/bad logic isn't helpful when all the endpoints for each CM all appear next to eachother. We have to iterate many of the same endpoints pointing to cm1-ord1 before getting to another host.

@azuisleet
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in d8a1f8b

Please sign in to comment.