@@ -16,6 +16,7 @@ static class ContentDownloader
16
16
const string DEFAULT_DIR = "depots" ;
17
17
const int MAX_STORAGE_RETRIES = 500 ;
18
18
const int MAX_CONNECT_RETRIES = 10 ;
19
+ const int NUM_STEAM3_CONNECTIONS = 4 ;
19
20
20
21
public static DownloadConfig Config = new DownloadConfig ( ) ;
21
22
@@ -522,31 +523,43 @@ private static void DownloadSteam3( int depotId, ulong depot_manifest, byte[] de
522
523
523
524
List < CDNClient . ClientEndPoint > cdnEndpoints = cdnServers . Where ( ( ep ) => { return ep . Type == "CDN" ; } ) . ToList ( ) ;
524
525
List < CDNClient . ClientEndPoint > csEndpoints = cdnServers . Where ( ( ep ) => { return ep . Type == "CS" ; } ) . ToList ( ) ;
525
- CDNClient cdnClient = null ;
526
+
527
+ List < CDNClient > cdnClients = new List < CDNClient > ( ) ;
526
528
527
529
foreach ( var server in csEndpoints )
528
530
{
529
531
CDNClient client = new CDNClient ( server , steam3 . AppTickets [ ( uint ) depotId ] ) ;
530
532
531
533
if ( client . Connect ( ) )
532
534
{
533
- cdnClient = client ;
534
- break ;
535
+ cdnClients . Add ( client ) ;
536
+
537
+ if ( cdnClients . Count >= NUM_STEAM3_CONNECTIONS )
538
+ break ;
535
539
}
536
540
}
537
541
538
- if ( cdnClient == null )
542
+ if ( cdnClients . Count == 0 )
539
543
{
540
544
Console . WriteLine ( "\n Could not initialize connection with CDN." ) ;
541
545
return ;
542
546
}
543
547
544
- DepotManifest depotManifest = cdnClient . DownloadDepotManifest ( depotId , depot_manifest ) ;
548
+ DepotManifest depotManifest = cdnClients [ 0 ] . DownloadDepotManifest ( depotId , depot_manifest ) ;
545
549
546
550
if ( depotManifest == null )
547
551
{
548
- Console . WriteLine ( "\n Unable to download manifest {0} for depot {1}" , depot_manifest , depotId ) ;
549
- return ;
552
+ // TODO: check for 401s
553
+ for ( int i = 1 ; i < cdnClients . Count && depotManifest == null ; i ++ )
554
+ {
555
+ depotManifest = cdnClients [ i ] . DownloadDepotManifest ( depotId , depot_manifest ) ;
556
+ }
557
+
558
+ if ( depotManifest == null )
559
+ {
560
+ Console . WriteLine ( "\n Unable to download manifest {0} for depot {1}" , depot_manifest , depotId ) ;
561
+ return ;
562
+ }
550
563
}
551
564
552
565
if ( ! depotManifest . DecryptFilenames ( depotKey ) )
@@ -602,7 +615,22 @@ private static void DownloadSteam3( int depotId, ulong depot_manifest, byte[] de
602
615
{
603
616
string chunkID = EncodeHexString ( chunk . ChunkID ) ;
604
617
605
- byte [ ] encrypted_chunk = cdnClient . DownloadDepotChunk ( depotId , chunkID ) ;
618
+ byte [ ] encrypted_chunk = cdnClients [ 0 ] . DownloadDepotChunk ( depotId , chunkID ) ;
619
+
620
+ if ( encrypted_chunk == null )
621
+ {
622
+ for ( int i = 1 ; i < cdnClients . Count && encrypted_chunk == null ; i ++ )
623
+ {
624
+ encrypted_chunk = cdnClients [ i ] . DownloadDepotChunk ( depotId , chunkID ) ;
625
+ }
626
+
627
+ if ( encrypted_chunk == null )
628
+ {
629
+ Console . WriteLine ( "Unable to download chunk id {0} for depot {1}" , chunkID , depotId ) ;
630
+ return ;
631
+ }
632
+ }
633
+
606
634
byte [ ] chunk_data = CDNClient . ProcessChunk ( encrypted_chunk , depotKey ) ;
607
635
608
636
fs . Seek ( ( long ) chunk . Offset , SeekOrigin . Begin ) ;
0 commit comments