Exemple #1
0
        private void OnMessageMyNick(ref MyNickMessage arg)
        {
            var ea = new TransferAuthorizationEventArgs {
                UserNickname = arg.Nickname
            };

            OnAuthorization(ea);

            if (!ea.Allowed || string.IsNullOrEmpty(ea.OwnNickname))
            {
                Logger.Info(RemoteAddress + " connection is not allowed");
                Dispose();
                return;
            }

            Source = new Source {
                UserNickname = arg.Nickname, HubAddress = ea.HubAddress
            };

            if (FirstMessages == null)
            {
                using (var transaction = new SendTransaction(this))
                {
                    transaction.Send(new MyNickMessage {
                        Nickname = ea.OwnNickname
                    }.Raw);
                    transaction.Send(new LockMessage().Raw);
                }
            }
        }
Exemple #2
0
        public void SendMyINFO(SendTransaction transaction = null)
        {
            var myInfo = new MyINFOMessage
            {
                Nickname = _currentUser.Nickname,
                Tag      =
                    string.Format("<{0},M:{1},H:{2},S:{3}{4}>", TagInfo.Version,
                                  Settings.PassiveMode ? "P" : "A", "0/0/0", "100",
                                  string.IsNullOrEmpty(TagInfo.City) ? "" : ",C:" + TagInfo.City),
                Connection = TagInfo.Connection,
                Flag       = TagInfo.Flag,
                Share      = _settings.FakeShare == 0 ? _currentUser.Share : _settings.FakeShare
            };

            if (!myInfo.Equals(_prevMessage))
            {
                if (transaction == null)
                {
                    SendMessage(myInfo.Raw);
                }
                else
                {
                    transaction.Send(myInfo.Raw);
                }
            }

            _prevMessage = myInfo;
        }
Exemple #3
0
        private void OnMessageLock(ref LockMessage lockMsg)
        {
            using (var transaction = new SendTransaction(this))
            {
                if (lockMsg.ExtendedProtocol)
                {
                    transaction.Send(new SupportsMessage {
                        NoHello = true, NoGetINFO = true, UserIP2 = true
                    }.Raw);
                }

                transaction.Send(lockMsg.CreateKey().Raw);
                transaction.Send(new ValidateNickMessage {
                    Nick = _currentUser.Nickname
                }.Raw);
            }
        }
Exemple #4
0
        private void OnMessageHello(ref HelloMessage helloMessage)
        {
            using (var transaction = new SendTransaction(this))
            {
                transaction.Send(new VersionMessage().Raw);
                if (Settings.GetUsersList)
                {
                    transaction.Send(new GetNickListMessage().Raw);
                }
                SendMyINFO(transaction);
            }

            if (!Settings.GetUsersList)
            {
                // tell everybody that we are ready to work
                Active = true;
            }
        }
Exemple #5
0
        private void OnMessageLock(ref LockMessage lockMessage)
        {
            using (var transaction = new SendTransaction(this))
            {
                if (lockMessage.ExtendedProtocol)
                {
                    transaction.Send(new SupportsMessage {
                        ADCGet = true, TTHF = true, TTHL = true
                    }.Raw);
                }

                var r = new Random();
                _ourNumer = r.Next(0, 32768);
                transaction.Send(new DirectionMessage {
                    Download = GetNewDownloadItem(), Number = _ourNumer
                }.Raw);
                transaction.Send(lockMessage.CreateKey().Raw);
            }
        }
Exemple #6
0
        protected override void SendFirstMessages()
        {
            if (FirstMessages == null || FirstMessages.Length == 0)
            {
                return;
            }

            using (var transaction = new SendTransaction(this))
                foreach (var message in FirstMessages)
                {
                    transaction.Send(message);
                }
        }