Beispiel #1
0
    public void Init(TcpClient client)
    {
        if (disposed)
        {
            throw new ObjectDisposedException("Session has been disposed.");
        }

        // Allow client to close immediately
        client.LingerState = new LingerOption(true, 0);
        name = client.Client.RemoteEndPoint?.ToString() ?? "Unknown";

        byte[] sivBytes = RandomNumberGenerator.GetBytes(4);
        byte[] rivBytes = RandomNumberGenerator.GetBytes(4);
        this.siv = BitConverter.ToUInt32(sivBytes);
        this.riv = BitConverter.ToUInt32(rivBytes);

        this.client        = client;
        this.networkStream = client.GetStream();
        this.sendCipher    = new MapleCipher.Encryptor(VERSION, siv, BLOCK_IV);
        this.recvCipher    = new MapleCipher.Decryptor(VERSION, riv, BLOCK_IV);
    }
Beispiel #2
0
    public void Init([NotNull] TcpClient client)
    {
        if (Disposed)
        {
            throw new ObjectDisposedException("Session has been disposed.");
        }

        // Allow client to close immediately
        client.LingerState = new(true, 0);
        Name = client.Client.RemoteEndPoint?.ToString();

        byte[] sivBytes = new byte[4];
        byte[] rivBytes = new byte[4];
        Rng.GetBytes(sivBytes);
        Rng.GetBytes(rivBytes);
        Siv = BitConverter.ToUInt32(sivBytes);
        Riv = BitConverter.ToUInt32(rivBytes);

        Client        = client;
        NetworkStream = client.GetStream();
        SendCipher    = new(VERSION, Siv, BLOCK_IV);
        RecvCipher    = new(VERSION, Riv, BLOCK_IV);
    }