mirror of
				https://github.com/esiur/esiur-dotnet.git
				synced 2025-10-29 23:21:36 +00:00 
			
		
		
		
	up
This commit is contained in:
		| @@ -892,22 +892,25 @@ public partial class DistributedConnection : NetworkConnection, IStore | |||||||
|                                     } |                                     } | ||||||
|                                     else |                                     else | ||||||
|                                     { |                                     { | ||||||
|                                         //Console.WriteLine("User not found"); |                                         // Send user not found error | ||||||
|                                         SendParams().AddUInt8(0xc0) |                                         SendParams().AddUInt8(0xc0) | ||||||
|                                                     .AddUInt8((byte)ExceptionCode.UserOrTokenNotFound) |                                                     .AddUInt8((byte)ExceptionCode.UserOrTokenNotFound) | ||||||
|                                                     .AddUInt16(14) |                                                     .AddUInt16(14) | ||||||
|                                                     .AddString("User not found").Done(); |                                                     .AddString("User not found") | ||||||
|  |                                                     .Done(); | ||||||
|                                     } |                                     } | ||||||
|                                 }); |                                 }); | ||||||
|                             } |                             } | ||||||
|                             catch (Exception ex) |                             catch (Exception ex) | ||||||
|                             { |                             { | ||||||
|  |                                 // Send the server side error | ||||||
|                                 var errMsg = DC.ToBytes(ex.Message); |                                 var errMsg = DC.ToBytes(ex.Message); | ||||||
|  |  | ||||||
|                                 SendParams().AddUInt8(0xc0) |                                 SendParams().AddUInt8(0xc0) | ||||||
|                                     .AddUInt8((byte)ExceptionCode.GeneralFailure) |                                     .AddUInt8((byte)ExceptionCode.GeneralFailure) | ||||||
|                                     .AddUInt16((ushort)errMsg.Length) |                                     .AddUInt16((ushort)errMsg.Length) | ||||||
|                                     .AddUInt8Array(errMsg).Done(); |                                     .AddUInt8Array(errMsg) | ||||||
|  |                                     .Done(); | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                         else if (authPacket.RemoteMethod == AuthenticationMethod.Token && authPacket.LocalMethod == AuthenticationMethod.None) |                         else if (authPacket.RemoteMethod == AuthenticationMethod.Token && authPacket.LocalMethod == AuthenticationMethod.None) | ||||||
| @@ -941,7 +944,7 @@ public partial class DistributedConnection : NetworkConnection, IStore | |||||||
|                                         } |                                         } | ||||||
|                                         else |                                         else | ||||||
|                                         { |                                         { | ||||||
|                                             //Console.WriteLine("User not found"); |                                             // Send token not found error. | ||||||
|                                             SendParams() |                                             SendParams() | ||||||
|                                                         .AddUInt8(0xc0) |                                                         .AddUInt8(0xc0) | ||||||
|                                                         .AddUInt8((byte)ExceptionCode.UserOrTokenNotFound) |                                                         .AddUInt8((byte)ExceptionCode.UserOrTokenNotFound) | ||||||
| @@ -954,6 +957,8 @@ public partial class DistributedConnection : NetworkConnection, IStore | |||||||
|                             } |                             } | ||||||
|                             catch (Exception ex) |                             catch (Exception ex) | ||||||
|                             { |                             { | ||||||
|  |                                 // Sender server side error. | ||||||
|  |  | ||||||
|                                 var errMsg = DC.ToBytes(ex.Message); |                                 var errMsg = DC.ToBytes(ex.Message); | ||||||
|  |  | ||||||
|                                 SendParams() |                                 SendParams() | ||||||
| @@ -980,6 +985,7 @@ public partial class DistributedConnection : NetworkConnection, IStore | |||||||
|                                 } |                                 } | ||||||
|                                 else |                                 else | ||||||
|                                 { |                                 { | ||||||
|  |                                     // Send access denied error because the server does not allow guests. | ||||||
|                                     SendParams() |                                     SendParams() | ||||||
|                                                 .AddUInt8(0xc0) |                                                 .AddUInt8(0xc0) | ||||||
|                                                 .AddUInt8((byte)ExceptionCode.AccessDenied) |                                                 .AddUInt8((byte)ExceptionCode.AccessDenied) | ||||||
| @@ -990,6 +996,7 @@ public partial class DistributedConnection : NetworkConnection, IStore | |||||||
|                             } |                             } | ||||||
|                             catch (Exception ex) |                             catch (Exception ex) | ||||||
|                             { |                             { | ||||||
|  |                                 // Send the server side error. | ||||||
|                                 var errMsg = DC.ToBytes(ex.Message); |                                 var errMsg = DC.ToBytes(ex.Message); | ||||||
|  |  | ||||||
|                                 SendParams().AddUInt8(0xc0) |                                 SendParams().AddUInt8(0xc0) | ||||||
| @@ -1035,22 +1042,31 @@ public partial class DistributedConnection : NetworkConnection, IStore | |||||||
|                                                                             .AddUInt8Array(remoteNonce) |                                                                             .AddUInt8Array(remoteNonce) | ||||||
|                                                                             .AddUInt8Array(localNonce) |                                                                             .AddUInt8Array(localNonce) | ||||||
|                                                                             .ToArray()); |                                                                             .ToArray()); | ||||||
|  |  | ||||||
|                                         if (hash.SequenceEqual(remoteHash)) |                                         if (hash.SequenceEqual(remoteHash)) | ||||||
|                                         { |                                         { | ||||||
|                                             // send our hash |                                             // send our hash | ||||||
|                                             //var localHash = hashFunc.ComputeHash(BinaryList.ToBytes(localNonce, remoteNonce, pw)); |                                             //var localHash = hashFunc.ComputeHash(BinaryList.ToBytes(localNonce, remoteNonce, pw)); | ||||||
|                                             //SendParams((byte)0, localHash); |                                             //SendParams((byte)0, localHash); | ||||||
|  |  | ||||||
|                                             var localHash = hashFunc.ComputeHash((new BinaryList()).AddUInt8Array(localNonce).AddUInt8Array(remoteNonce).AddUInt8Array(pw).ToArray()); |                                             var localHash = hashFunc.ComputeHash((new BinaryList()) | ||||||
|  |                                                                 .AddUInt8Array(localNonce) | ||||||
|  |                                                                 .AddUInt8Array(remoteNonce) | ||||||
|  |                                                                 .AddUInt8Array(pw) | ||||||
|  |                                                                 .ToArray()); | ||||||
|  |  | ||||||
|                                             SendParams().AddUInt8(0).AddUInt8Array(localHash).Done(); |                                             SendParams() | ||||||
|  |                                                 .AddUInt8(0) | ||||||
|  |                                                 .AddUInt8Array(localHash) | ||||||
|  |                                                 .Done(); | ||||||
|  |  | ||||||
|                                             readyToEstablish = true; |                                             readyToEstablish = true; | ||||||
|                                         } |                                         } | ||||||
|                                         else |                                         else | ||||||
|                                         { |                                         { | ||||||
|                                             //Global.Log("auth", LogType.Warning, "U:" + RemoteUsername + " IP:" + Socket.RemoteEndPoint.Address.ToString() + " S:DENIED"); |                                             //Global.Log("auth", LogType.Warning, "U:" + RemoteUsername + " IP:" + Socket.RemoteEndPoint.Address.ToString() + " S:DENIED"); | ||||||
|                                             SendParams().AddUInt8(0xc0) |                                             SendParams() | ||||||
|  |                                                 .AddUInt8(0xc0) | ||||||
|                                                 .AddUInt8((byte)ExceptionCode.AccessDenied) |                                                 .AddUInt8((byte)ExceptionCode.AccessDenied) | ||||||
|                                                 .AddUInt16(13) |                                                 .AddUInt16(13) | ||||||
|                                                 .AddString("Access Denied") |                                                 .AddString("Access Denied") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user