Example #1
0
        public void Start(SksClientType clientType)
        {
            Logger.Log(GetWholeLogTag(), "Start");

            lock (countLock)
            {
                if (MessageCount != 0)
                {
                    // todo: ERROR - nejake spravy uz boli poslane..
                    return;
                }
            }

            if (clientType == SksClientType.Local)
            {
                // todo: add TTPs
                var message = new HandshakeMessage1(Lib.MyUsername, User.Name, KeyId, PasswordId, null);
                User.SendMessage(message.ToString());
            }

            IncrementMessageCount();
        }
Example #2
0
        private static void HandleHandshakeMessage1(SksMessageReceivedEventArgs sksMessageReceivedEventArgs)
        {
            var user = GetUserByIpAndPort(sksMessageReceivedEventArgs.FromIp, sksMessageReceivedEventArgs.FromPort);

            Handshake handshake;

            lock (handshakesLock)
            {
                handshake = Handshakes.FirstOrDefault(h => h.User == user);
            }

            if (handshake != null)
            {
                Logger.Log(LogTag, "ERROR: Handshake message 1 - handshake already existed");
                return;
            }

            handshake = InitHandshake(user, SksClientType.Remote);

            if (handshake == null)
            {
                return;
            }

            var message = HandshakeMessage1.FromString(sksMessageReceivedEventArgs.Message);

            user.Protocol = Utils.DetermineProtocol(user);

            if (user.Protocol == ProtocolType.LamportScheme)
            {
                InitLamportScheme(user, SksClientType.Remote);
            }

            var newMessage = new HandshakeMessage2(user.Protocol, null);

            user.SendMessage(newMessage.ToString());

            handshake.IncrementMessageCount();
        }