diff --git a/client/src/sock/Connection.ts b/client/src/sock/Connection.ts index 67e5aa5..8c81704 100644 --- a/client/src/sock/Connection.ts +++ b/client/src/sock/Connection.ts @@ -54,7 +54,7 @@ class Connection { CriticalStop.redirect("Could not establish an encrypted connection with the server."); break; case kPacketId.LoginAttempt: - + break; case kPacketId.RegistrationAttempt: diff --git a/server/Encryption/KeyExchange.cs b/server/Encryption/KeyExchange.cs index 3c3b2d0..10b8899 100644 --- a/server/Encryption/KeyExchange.cs +++ b/server/Encryption/KeyExchange.cs @@ -9,7 +9,7 @@ using System.Globalization; namespace CircleScape.Encryption { class Key { - private BigInteger Secret; + private readonly static BigInteger Secret = RNG.NextPrime(512 / 8); public BigInteger Generator { get; private set; } = 2; public BigInteger Modulus { get; private set; } public BigInteger PrivateKey { get; private set; } = BigInteger.Zero; @@ -18,7 +18,6 @@ namespace CircleScape.Encryption { } public Key() { - Secret = RNG.NextPrime(512 / 8); Modulus = RNG.NextPrime(512 / 8); } diff --git a/server/Libraries/Kneesocks/Connection.cs b/server/Libraries/Kneesocks/Connection.cs index 1ab5a71..bf9df61 100644 --- a/server/Libraries/Kneesocks/Connection.cs +++ b/server/Libraries/Kneesocks/Connection.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Square; using System.IO; +using System.Net; namespace Kneesocks { public class Connection { @@ -55,6 +56,12 @@ namespace Kneesocks { public bool Handshaked { get; private set; } = false; public Handshake ClientHandshake { get; private set; } = null; + public IPAddress IP { + get { + return ((IPEndPoint)Socket.Client.RemoteEndPoint).Address; + } + } + public void Initialize(TcpClient sock) { if(Initialized) return; diff --git a/server/Socks/ActiveConnection.cs b/server/Socks/ActiveConnection.cs index 04a2279..e9f19ab 100644 --- a/server/Socks/ActiveConnection.cs +++ b/server/Socks/ActiveConnection.cs @@ -8,13 +8,12 @@ using Kneesocks; using CircleScape.Encryption; namespace CircleScape { - class ActiveConnection : Kneesocks.Connection { + class ActiveConnection : Connection { private Cipher Encryptor; public void Initialize(PendingConnection conn) { Initialize(conn, false); Encryptor = conn.Encryptor; - } } } diff --git a/server/Socks/PendingConnection.cs b/server/Socks/PendingConnection.cs index 948cfb8..01fa2ac 100644 --- a/server/Socks/PendingConnection.cs +++ b/server/Socks/PendingConnection.cs @@ -47,6 +47,12 @@ namespace CircleScape { Encryptor = new Cipher(Key.PrivateKey); break; + case Packet.kId.LoginAttempt: + + break; + default: + Disconnect(Frame.kClosingReason.ProtocolError, "Packet ID could not be understood at this time."); + break; } Console.WriteLine(Id + " says " + data.GetString()); diff --git a/server/scape.db b/server/scape.db index 2504da1..df3a227 100644 Binary files a/server/scape.db and b/server/scape.db differ