コード例 #1
0
        /// <summary>
        /// This is a request to remove the remote host from our list of current connections.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private byte[] Delete(OSDMap request)
        {
            IWCConnection Certificate = new IWCConnection();

            //Pull the connection info out of the request
            Certificate.FromOSD(request);

            //Make sure that they are verified to connect
            if (!CertificateVerification.VerifyConnection(Certificate))
            {
                return(FailureResult());
            }

            //Remove them from our list of connections
            CertificateVerification.RemoveCertificate(Certificate);

            return(SuccessfulResult());
        }
コード例 #2
0
        /// <summary>
        /// This is the initial request to join this host
        /// We need to verify passwords and add sessionHashes to our database
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private byte[] Query(OSDMap requestMap)
        {
            IWCConnection incomingConnectionRequest = new IWCConnection();

            //Pull the connection info out of the request
            incomingConnectionRequest.FromOSD(requestMap);

            IWCCertificate incomingCertificate = null;

            //Lets make sure that they are allowed to connect to us
            if (!CertificateVerification.VerifyConnection(incomingConnectionRequest))
            {
                //Make sure the other host is not trying to spoof one of our certificates
                if (CertificateVerification.GetCertificateByUserName(incomingConnectionRequest.UserName) != null)
                {
                    //SPOOF! XXXXXX
                    return(FailureResult());
                }
                //This is an untrusted connection otherwise
                if (!IWC.m_allowUntrustedConnections)
                {
                    return(FailureResult()); //We don't allow them
                }
            }
            else
            {
                incomingCertificate = CertificateVerification.GetCertificateByUserName(incomingConnectionRequest.UserName);
            }

            if (incomingCertificate == null)
            {
                incomingCertificate            = new IWCCertificate();
                incomingCertificate.Connection = new IWCConnection(incomingConnectionRequest);
                //Got to flip the URLs so that we send to the right place later
                incomingCertificate.Connection.RecieverURL = incomingCertificate.Connection.SenderURL;
                //And add our SenderURL to the connection
                IHttpServer server = IWC.Registry.RequestModuleInterface <ISimulationBase> ().GetHttpServer(0);
                incomingCertificate.Connection.SenderURL = server.HostName + ":" + server.Port + "/iwcconnection";

                //If we don't know it, its the default trust level
                incomingCertificate.ThreatLevel = IWC.m_untrustedConnectionsDefaultTrust;
                incomingCertificate.Active      = true;
                incomingCertificate.ValidUntil  = DateTime.Now.AddDays(1);
            }

            //Update them in the database so that they can connect again later
            CertificateVerification.AddCertificate(incomingCertificate);

            //Read the URLs they sent to us
            IWC.ParseIWCCertificateForURLs(incomingCertificate);

            //Now send them back some URLs as well
            IWC.BuildSecureUrlsForConnection(incomingCertificate);

            //Fix the SecureURLs
            incomingConnectionRequest.SecureUrls = incomingCertificate.Connection.SecureUrls;
            OSDMap result = incomingConnectionRequest.ToOSD(false);

            result["Result"] = "Successful";

            m_log.WarnFormat("[IWC]: {0} successfully connected to us.", incomingConnectionRequest.SenderURL);

            return(Return(result));
        }