@ -123,29 +123,48 @@ namespace DepotDownloader
return false ;
}
public static void Download ( int depotId , int depotVersion , int cellId , string username , string password , bool onlyManifest , bool gameServer , bool exclude , string installDir , string [ ] fileList )
static bool DepotHasSteam3Manifest ( int depotId , out string manifest_id )
{
if ( ! CreateDirectories ( depotId , depotVersion , ref installDir ) )
if ( steam3 = = null | | steam3 . AppInfo = = null )
{
Console. WriteLine ( "Error: Unable to create install directories!" ) ;
return ;
manifest_id = null ;
return false ;
}
Console . Write ( "Finding content servers..." ) ;
IPEndPoint contentServer = GetStorageServer ( depotId , depotVersion , cellId ) ;
foreach ( var app in steam3 . AppInfo )
{
KeyValue depots ;
if ( app . AppID = = depotId & & app . Sections . TryGetValue ( ( int ) EAppInfoSection . AppInfoSectionDepots , out depots ) )
{
string key = depotId . ToString ( ) ;
var node = depots . Children . Where ( a = > a . Name = = key ) . First ( ) . Children
. Where ( b = > b . Name = = key ) . First ( ) . Children
. Where ( c = > c . Name = = "manifests" ) . First ( ) . Children
. Where ( d = > d . Name = = "Public" ) . First ( ) ;
if ( contentServer = = null )
manifest_id = node . AsString ( null ) ;
return true ;
}
}
manifest_id = null ;
return false ;
}
public static void Download ( int depotId , int depotVersion , int cellId , string username , string password , bool onlyManifest , bool gameServer , bool exclude , string installDir , string [ ] fileList )
{
Console . WriteLine ( "\nError: Unable to find any content servers for depot {0}, version {1}" , depotId , depotVersion ) ;
if ( ! CreateDirectories ( depotId , depotVersion , ref installDir ) )
{
Console . WriteLine ( "Error: Unable to create install directories!" ) ;
return ;
}
Console . WriteLine ( " Done!" ) ;
ContentServerClient . Credentials credentials = null ;
if ( username ! = null )
{
// ServerCache.BuildAuthServers( username );
credentials = GetCredentials ( ( uint ) depotId , username , password ) ;
}
@ -160,6 +179,60 @@ namespace DepotDownloader
return ;
}
string steam3_manifest = null ;
if ( DepotHasSteam3Manifest ( depotId , out steam3_manifest ) )
{
DownloadSteam3 ( credentials , depotId , depotVersion , cellId ) ;
}
else
{
DownloadSteam2 ( credentials , depotId , depotVersion , cellId , username , password , onlyManifest , gameServer , exclude , installDir , fileList ) ;
}
if ( steam3 ! = null )
steam3 . Disconnect ( ) ;
}
private static void DownloadSteam3 ( ContentServerClient . Credentials credentials , int depotId , int depotVersion , int cellId )
{
Console . Write ( "Finding content servers..." ) ;
/ * IPEndPoint contentServer = GetAnyStorageServer ( ) ;
if ( contentServer = = null )
{
Console . WriteLine ( "\nError: Unable to find any content servers" ) ;
return ;
}
* /
// find a proper bootstrap...
IPEndPoint contentServer1 = new IPEndPoint ( IPAddress . Parse ( "4.28.20.42" ) , 80 ) ;
List < IPEndPoint > cdnServers = CDNClient . FetchServerList ( contentServer1 , cellId ) ;
Console . WriteLine ( " Done!" ) ;
CDNClient cdnClient = new CDNClient ( cdnServers [ 0 ] , credentials . AppTicket ) ;
if ( ! cdnClient . Connect ( ) )
{
Console . WriteLine ( "\nCould not initialize connection with CDN." ) ;
return ;
}
}
private static void DownloadSteam2 ( ContentServerClient . Credentials credentials , int depotId , int depotVersion , int cellId , string username , string password , bool onlyManifest , bool gameServer , bool exclude , string installDir , string [ ] fileList )
{
Console . Write ( "Finding content servers..." ) ;
IPEndPoint contentServer = GetStorageServer ( depotId , depotVersion , cellId ) ;
if ( contentServer = = null )
{
Console . WriteLine ( "\nError: Unable to find any content servers for depot {0}, version {1}" , depotId , depotVersion ) ;
return ;
}
Console . WriteLine ( " Done!" ) ;
string manifestFile = Path . Combine ( installDir , "manifest.bin" ) ;
string txtManifest = Path . Combine ( installDir , "manifest.txt" ) ;
@ -313,9 +386,6 @@ namespace DepotDownloader
csClient . Disconnect ( ) ;
if ( steam3 ! = null )
steam3 . Disconnect ( ) ;
}
static ContentServerClient . Credentials GetCredentials ( uint depotId , string username , string password )
@ -374,6 +444,31 @@ namespace DepotDownloader
return null ;
}
static IPEndPoint GetAnyStorageServer ( )
{
foreach ( IPEndPoint csdServer in ServerCache . CSDSServers )
{
ContentServerDSClient csdsClient = new ContentServerDSClient ( ) ;
csdsClient . Connect ( csdServer ) ;
IPEndPoint [ ] servers = csdsClient . GetContentServerList ( ) ;
if ( servers = = null )
{
Console . WriteLine ( "Warning: CSDS {0} returned empty server list." , csdServer ) ;
continue ;
}
if ( servers . Length = = 0 )
continue ;
return servers [ PsuedoRandom . GetRandomInt ( 0 , servers . Length - 1 ) ] ;
}
return null ;
}
static IPEndPoint GetAuthServer ( )
{
if ( ServerCache . AuthServers . Count > 0 )