Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.32 KB | None | 0 0
  1.  
  2.     class LoginData
  3.     {
  4.         public ClientTGT ClientTGT;
  5.         public byte[] ServerTGT;
  6.         public byte[] AccountRecord;
  7.     }
  8.  
  9.     class LoginCall : SteamCallHandle
  10.     {
  11.         string userName;
  12.         string password;
  13.  
  14.         AuthServerClient asClient;
  15.  
  16.         IPEndPoint authServer;
  17.  
  18.         LoginData loginData;
  19.  
  20.  
  21.         public LoginCall( string userName, string password )
  22.         {
  23.             this.userName = userName;
  24.             this.password = password;
  25.  
  26.             this.loginData = new LoginData();
  27.  
  28.             this.asClient = new AuthServerClient();
  29.  
  30.             this.FuncCalls.Add( Step1 );
  31.             this.FuncCalls.Add( Step2 );
  32.             this.FuncCalls.Add( Step3 );
  33.             this.FuncCalls.Add( Step4 );
  34.             this.FuncCalls.Add( Step5 );
  35.             this.FuncCalls.Add( Step6 );
  36.  
  37.             base.Start();
  38.         }
  39.  
  40.  
  41.         // find auth server for username
  42.         bool Step1( ref SteamProgress progress, out SteamError error )
  43.         {
  44.             error = new SteamError();
  45.             progress.Description = "Finding auth server...";
  46.  
  47.             GeneralDSClient gdsClient = new GeneralDSClient();
  48.  
  49.             IPEndPoint[] authServers = gdsClient.GetServerList( GeneralDSClient.GDServers[ 0 ], EServerType.ProxyASClientAuthentication, this.userName );
  50.  
  51.             if ( authServers == null )
  52.             {
  53.                 error = new SteamError( SteamErrorCode.NoConnectivity );
  54.                 return false;
  55.             }
  56.  
  57.             if ( authServers.Length == 0 )
  58.             {
  59.                 error = new SteamError( SteamErrorCode.NoAuthServersAvailable );
  60.                 return false;
  61.             }
  62.  
  63.             authServer = authServers[ 0 ];
  64.             return true;
  65.         }
  66.  
  67.         // connect to auth server
  68.         bool Step2( ref SteamProgress progress, out SteamError error )
  69.         {
  70.             error = new SteamError();
  71.             progress.Description = "Connecting...";
  72.  
  73.             if ( !asClient.Connect( authServer ) )
  74.             {
  75.                 error = new SteamError( SteamErrorCode.NoConnectivity );
  76.                 return false;
  77.             }
  78.  
  79.             return true;
  80.         }
  81.  
  82.         // verify protocol and get ip
  83.         bool Step3( ref SteamProgress progress, out SteamError error )
  84.         {
  85.             error = new SteamError();
  86.             progress.Description = "Verifying...";
  87.  
  88.  
  89.             if ( !asClient.RequestIP() )
  90.             {
  91.                 error = new SteamError( SteamErrorCode.NoConnectivity );
  92.                 return false;
  93.             }
  94.  
  95.             return true;
  96.         }
  97.  
  98.         // send username command, and get salt reply
  99.         bool Step4( ref SteamProgress progress, out SteamError error )
  100.         {
  101.             error = new SteamError();
  102.             progress.Description = string.Format( "Logging in '{0}'...", userName );
  103.  
  104.             if ( !asClient.GetSalt( userName ) )
  105.             {
  106.                 error = new SteamError( SteamErrorCode.NoConnectivity );
  107.                 return false;
  108.             }
  109.  
  110.             return true;
  111.         }
  112.  
  113.         // do actual login
  114.         bool Step5( ref SteamProgress progress, out SteamError error )
  115.         {
  116.             error = new SteamError();
  117.             progress.Description = string.Format( "Logging in '{0}'...", userName );
  118.  
  119.             if ( !asClient.SendLogin( password ) )
  120.             {
  121.                 error = new SteamError( SteamErrorCode.LoginFailed );
  122.                 return false;
  123.             }
  124.  
  125.             return true;
  126.         }
  127.  
  128.         // get acc info
  129.         bool Step6( ref SteamProgress progress, out SteamError error )
  130.         {
  131.             error = new SteamError();
  132.             progress.Description = string.Format( "Getting account information..." );
  133.  
  134.             if ( !asClient.GetAccountInfo( out loginData.ClientTGT, out loginData.ServerTGT, out loginData.AccountRecord ) )
  135.             {
  136.                 error = new SteamError( SteamErrorCode.LoginFailed );
  137.                 return false;
  138.             }
  139.  
  140.             return true;
  141.         }
  142.  
  143.         internal override object GetCompletionData()
  144.         {
  145.             return loginData;
  146.         }
  147.  
  148.         public override string ToString()
  149.         {
  150.             return string.Format( "LoginCall( \"{0}\" )", userName );
  151.         }
  152.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement