Ejemplo n.º 1
0
        // ============================================
        // PUBLIC Constructors
        // ============================================
        /// Create New Proxy Settings Dialog
        public AcceptUser(PeerSocket peer) :
            base("dialog", "AcceptUserDialog.glade")
        {
            // Get UserInfo
            UserInfo userInfo = peer.Info as UserInfo;

            // Initialize GUI
            this.labelTitle.Text = "<span size='x-large'><b>Accept User</b> (";
            if (userInfo.SecureAuthentication == true)
            {
                this.image.Pixbuf     = StockIcons.GetPixbuf("SecureAuth");
                this.labelTitle.Text += "Secure";
                this.Dialog.Title    += " (Secure Authentication)";
            }
            else
            {
                this.image.Pixbuf     = StockIcons.GetPixbuf("InsecureAuth");
                this.labelTitle.Text += "Insecure";
                this.Dialog.Title    += " (Insecure Authentication)";
            }
            this.labelTitle.Text     += ")</span>";
            this.labelTitle.UseMarkup = true;

            entryName.Text = userInfo.Name;
            entryIP.Text   = peer.GetRemoteIP().ToString();
        }
Ejemplo n.º 2
0
        // ============================================
        // PUBLIC STATIC Methods
        // ============================================
        /// Generate Peer's Magic
        public static string GenerateMagic(PeerSocket peer)
        {
            UserInfo myInfo    = MyInfo.GetInstance();
            string   userIp    = CryptoUtils.SHA1String(peer.GetRemoteIP().ToString());
            string   userMagic = CryptoUtils.SHA1String((string)myInfo.Informations["magic"]);

            return(CryptoUtils.MD5String(userIp + userMagic));
        }
 // ===================================================
 // PRIVATE (Methods) Protocol Event Handler
 // ===================================================
 private void OnAcceptFileEvent(PeerSocket peer, XmlRequest xml)
 {
     try {
         string   path     = (string)xml.Attributes["path"];
         UserInfo userInfo = peer.Info as UserInfo;
         UploadManager.Add(userInfo, path);
     } catch (Exception e) {
         Glue.Dialogs.MessageError("Accept File", "Peer Ip: " +
                                   peer.GetRemoteIP().ToString() + "\n" +
                                   e.Message);
     }
 }
Ejemplo n.º 4
0
            private void SendProtocolEvent(XmlRequest xmlRequest)
            {
                switch (xmlRequest.FirstTag)
                {
                case "login":
                    Login login = new Login(peer, xmlRequest);
                    if (login.Authentication() == true && login.User != null)
                    {
                        // Add to Known User
                        P2PManager.AddPeer(login.User, peer);

                        // Start Login Event
                        CmdManager.LoginEvent(peer, login.User);
                    }
                    else
                    {
                        Debug.Log("Auth Failed: {0}", peer.GetRemoteIP());
                    }
                    break;

                case "quit":
                    CmdManager.QuitEvent(peer, xmlRequest);
                    break;

                case "error":
                    CmdManager.ErrorEvent(peer, xmlRequest);
                    break;

                case "get":
                    CmdManager.GetEvent(peer, xmlRequest);
                    break;

                case "ask":
                    CmdManager.AskEvent(peer, xmlRequest);
                    break;

                case "snd":
                    CmdManager.SndEvent(peer, xmlRequest);
                    break;

                case "snd-start":
                    CmdManager.SndStartEvent(peer, xmlRequest);
                    break;

                case "snd-end":
                    CmdManager.SndEndEvent(peer, xmlRequest);
                    break;

                case "snd-abort":
                    CmdManager.SndAbortEvent(peer, xmlRequest);
                    break;

                case "recv-abort":
                    CmdManager.RecvAbortEvent(peer, xmlRequest);
                    break;

                default:
                    CmdManager.UnknownEvent(peer, xmlRequest);
                    break;
                }
            }
Ejemplo n.º 5
0
        private void ParseCommand(string xml)
        {
#if DEBUG
            Debug.Log("==================================================");
            if (peer.Info != null)
            {
                UserInfo userInfo = this.peer.Info as UserInfo;
                Debug.Log("Response From: {0}", userInfo.Name);
            }
            else
            {
                Debug.Log("Response From: {0}", peer.GetRemoteIP());
            }
            Debug.Log("Response: '{0}'", xml);
            Debug.Log("==================================================");
#endif

            // Parse Xml Command
            XmlRequest xmlRequest = null;
            try {
                xmlRequest = new XmlRequest(xml);
                xmlRequest.Parse();
            } catch (Exception e) {
                Debug.Log("Parse Xml: {0}", e.Message);
                return;
            }

            // Protocol Commands
            switch (xmlRequest.FirstTag)
            {
            case "login":
                Login login = new Login(peer, xmlRequest);
                if (login.Authentication() == true && login.User != null)
                {
                    // Add to Known User
                    P2PManager.AddPeer(login.User, peer);

                    // Start Login Event
                    CmdManager.StartLoginEvent(peer, login.User);
                }
                else
                {
                    Debug.Log("Auth Failed: {0}", peer.GetRemoteIP());
                }
                break;

            case "quit":
                CmdManager.StartQuitEvent(peer, xmlRequest);
                break;

            case "error":
                CmdManager.StartErrorEvent(peer, xmlRequest);
                break;

            case "get":
                CmdManager.StartGetEvent(peer, xmlRequest);
                break;

            case "ask":
                CmdManager.StartAskEvent(peer, xmlRequest);
                break;

            case "accept":
                CmdManager.StartAcceptEvent(peer, xmlRequest);
                break;

            case "snd":
                CmdManager.StartSndEvent(peer, xmlRequest);
                break;

            case "snd-start":
                CmdManager.StartSndStartEvent(peer, xmlRequest);
                break;

            case "snd-end":
                CmdManager.StartSndEndEvent(peer, xmlRequest);
                break;

            case "snd-abort":
                CmdManager.StartSndAbortEvent(peer, xmlRequest);
                break;

            case "recv-abort":
                CmdManager.StartRecvAbortEvent(peer, xmlRequest);
                break;

            default:
                CmdManager.StartUnknownEvent(peer, xmlRequest);
                break;
            }
        }