Pārlūkot izejas kodu

输入框输入登录地址,用户名以及密码

tanghai 13 gadi atpakaļ
vecāks
revīzija
50859235c3

+ 7 - 8
CSharp/App/Modules/Robot/RealmSession.cs

@@ -97,7 +97,7 @@ namespace Robot
 			return smsgPasswordProtectType;
 		}
 
-		public async Task<SMSG_Auth_Logon_Challenge_Response> 
+		public async Task<SMSG_Auth_Logon_Challenge_Response>
 			Handle_SMSG_Auth_Logon_Challenge_Response()
 		{
 			var result = await this.RecvMessage();
@@ -204,18 +204,17 @@ namespace Robot
 				s.ToByteArray(), account.ToByteArray(), password.ToByteArray());
 			BigInteger clientS = srp6Client.CalculateSecret(b);
 
-			Logger.Debug("N: {0}\nG: {1}, s: {2}, B: {3}, A: {4}, S: {5}",
-				smsgAuthLogonChallengeResponse.N.ToHex(), smsgAuthLogonChallengeResponse.G.ToHex(),
-				smsgAuthLogonChallengeResponse.S.ToHex(), smsgAuthLogonChallengeResponse.B.ToHex(),
-				a.ToByteArray().ToHex(), clientS.ToByteArray().ToHex());
-
 			var sha1Managed = new SHA1Managed();
 			byte[] k = SRP6Helper.SRP6ClientCalcK(sha1Managed, clientS.ToByteArray());
-			Logger.Debug("K: {0}", k.ToHex());
 			byte[] m = SRP6Helper.SRP6ClientM1(
 				sha1Managed, account.ToByteArray(), n.ToByteArray(), g.ToByteArray(), 
 				s.ToByteArray(), a.ToByteArray(), b.ToByteArray(), k);
-			Logger.Debug("M: {0}, size: {1}", m.ToHex(), m.Length);
+
+			Logger.Debug("N: {0}\nG: {1}\ns: {2}\nB: {3}\nA: {4}\nS: {5}\nK: {6}\nm: {7}",
+				smsgAuthLogonChallengeResponse.N.ToHex(), smsgAuthLogonChallengeResponse.G.ToHex(),
+				smsgAuthLogonChallengeResponse.S.ToHex(), smsgAuthLogonChallengeResponse.B.ToHex(),
+				a.ToByteArray().ToHex(), clientS.ToByteArray().ToHex(),
+				k.ToHex(), m.ToHex());
 
 			var cmsgAuthLogonProof = new CMSG_Auth_Logon_Proof
 			{

+ 2 - 1
CSharp/App/Modules/Robot/Robot.csproj

@@ -32,7 +32,8 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="BouncyCastle.Crypto">
+    <Reference Include="BouncyCastle.Crypto, Version=1.7.4137.9283, Culture=neutral, PublicKeyToken=a4292a325f69b123, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\..\packages\BouncyCastle.1.7.0\lib\Net20\BouncyCastle.Crypto.dll</HintPath>
     </Reference>
     <Reference Include="Microsoft.Practices.Prism">

+ 7 - 3
CSharp/App/Modules/Robot/RobotView.xaml

@@ -8,10 +8,14 @@
 	<Grid>
 		<StackPanel>
 			<StackPanel Orientation="Horizontal" >
-				<Label Content="loginIp: "></Label>
-				<TextBox Width="120" Text="{Binding LoginIp}" />
-				<Label Content="loginPort: "></Label>
+				<Label Content="LoginIP: "></Label>
+				<TextBox Width="120" Text="{Binding LoginIP}" />
+				<Label Content="LoginPort: "></Label>
 				<TextBox Width="40" Text="{Binding LoginPort}" />
+				<Label Content="Account: "></Label>
+				<TextBox Width="120" Text="{Binding Account}" />
+				<Label Content="Password: "></Label>
+				<TextBox Width="120" Text="{Binding Password}" />
 				<Button Name="btnStart" Content="Login" Width="80" Height="25" Click="btnLogin_Click" />
 				<TextBlock></TextBlock>
 			</StackPanel>

+ 1 - 1
CSharp/App/Modules/Robot/RobotView.xaml.cs

@@ -30,7 +30,7 @@ namespace Modules.Robot
 
 		private void btnLogin_Click(object sender, RoutedEventArgs e)
 		{
-			this.ViewModel.Login("egametang@163.com", "163bio1");
+			this.ViewModel.Login();
 		}
 	}
 }

+ 46 - 29
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -13,25 +13,27 @@ namespace Modules.Robot
 	internal sealed class RobotViewModel: NotificationObject, IDisposable
 	{
 		private readonly ClientHost clientHost;
-		private string loginIp;
-		private ushort loginPort;
+		private string loginIP = "192.168.11.95";
+		private ushort loginPort = 8888;
+		private string account = "egametang";
+		private string password = "163bio1";
 
 		private readonly DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Normal)
 		{ Interval = new TimeSpan(0, 0, 0, 0, 50) };
 
-		public string LoginIp
+		public string LoginIP
 		{
 			get
 			{
-				return this.loginIp;
+				return this.loginIP;
 			}
 			set
 			{
-				if (this.loginIp == value)
+				if (this.loginIP == value)
 				{
 					return;
 				}
-				this.loginIp = value;
+				this.loginIP = value;
 				this.RaisePropertyChanged("LoginIp");
 			}
 		}
@@ -53,6 +55,40 @@ namespace Modules.Robot
 			}
 		}
 
+		public string Account
+		{
+			get
+			{
+				return this.account;
+			}
+			set
+			{
+				if (this.account == value)
+				{
+					return;
+				}
+				this.account = value;
+				this.RaisePropertyChanged("Account");
+			}
+		}
+
+		public string Password
+		{
+			get
+			{
+				return this.password;
+			}
+			set
+			{
+				if (this.password == value)
+				{
+					return;
+				}
+				this.password = value;
+				this.RaisePropertyChanged("Password");
+			}
+		}
+
 		public RobotViewModel()
 		{
 			this.clientHost = new ClientHost();
@@ -77,36 +113,17 @@ namespace Modules.Robot
 			this.clientHost.Dispose();
 		}
 
-		public void Login(string account, string password)
+		public void Login()
 		{
-			//try
-			//{
-			//	var address = new Address { HostName = this.LoginIp, Port = this.LoginPort };
-			//	Peer peer = await this.clientHost.ConnectAsync(address);
-			//	using (Packet packet = await peer.ReceiveAsync())
-			//	{
-			//		var bytes = packet.Bytes;
-			//		var packetStream = new MemoryStream(bytes, 4, bytes.Length - 4);
-			//		var smsg = Serializer.Deserialize<SMSG_Auth_Challenge>(packetStream);
-			//		Logger.Debug(string.Format("opcode: {0}\n{1}",
-			//			BitConverter.ToUInt16(bytes, 0), XmlHelper.XmlSerialize(smsg)));
-			//		await peer.DisconnectLaterAsync();
-			//	}
-			//}
-			//catch (Exception e)
-			//{
-			//	Logger.Debug(e.Message);
-			//}
-
-			var session = new RealmSession("192.168.11.95", 8888);
+			var session = new RealmSession(this.LoginIP, this.LoginPort);
 
 			try
 			{
-				session.Login(account, password);
+				session.Login(this.Account, this.Password);
 			}
 			catch (Exception e)
 			{
-				Logger.Trace("recv exception: {0}, {1}", e.Message, e.StackTrace);
+				Logger.Trace("realm exception: {0}, {1}", e.Message, e.StackTrace);
 				return;
 			}
 

+ 0 - 12
CSharp/App/Modules/Robot/SRP6Client.cs

@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Robot
-{
-	class SRP6Client
-	{
-	}
-}