public override IDataTransferable Duplicate() { IWCConnection m = new IWCConnection(); m.FromOSD(ToOSD()); return(m); }
public override void FromOSD(OSDMap map) { Connection = new IWCConnection(); Connection.FromOSD(map); ValidUntil = map["ValidUntil"].AsDate(); Active = map["Active"].AsBoolean(); ThreatLevel = (ThreatLevel)map["ThreatLevel"].AsInteger(); }
/// <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()); }
/// <summary> /// Query the given host (by connection) and verify that we can connect to it. /// </summary> /// <param name="connector">The host to connect to</param> /// <returns>The connection that has been recieved from the host</returns> public IWCConnection QueryRemoteHost(IWCConnection connection) { OSDMap request = connection.ToOSD(false); request["Method"] = "Query"; OSDMap reply = WebUtils.PostToService(connection.RecieverURL, request); if (reply["Success"].AsBoolean()) { if (reply["_Result"].Type != OSDType.Map) { m_log.Warn("[IWC]: Unable to connect successfully to " + connection.RecieverURL + ", connection did not have all the required data."); return(null); } OSDMap innerReply = (OSDMap)reply["_Result"]; if (innerReply["Result"].AsString() == "Successful") { IWCConnection c = new IWCConnection(); c.FromOSD(innerReply); IWCCertificate cert = new IWCCertificate(); cert.Connection = new IWCConnection(); cert.Active = true; cert.Connection.SenderURL = c.SenderURL; cert.Connection.RecieverURL = c.RecieverURL; cert.Connection.UserName = c.UserName; cert.Connection.Password = c.Password; cert.Connection.SecureUrls = c.SecureUrls; m_log.Error("[IWC]: Connected successfully to " + connection.RecieverURL); return(c); } m_log.Warn("[IWC]: Unable to connect successfully to " + connection.RecieverURL + ", " + innerReply["Result"]); } else { m_log.Warn("[IWC]: Unable to connect successfully to " + connection.RecieverURL); } return(null); }
/// <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)); }
public override IDataTransferable Duplicate () { IWCConnection m = new IWCConnection (); m.FromOSD (ToOSD ()); return m; }
public override void FromOSD(OSDMap map) { Connection = new IWCConnection (); Connection.FromOSD (map); ValidUntil = map["ValidUntil"].AsDate (); Active = map["Active"].AsBoolean (); ThreatLevel = (ThreatLevel)map["ThreatLevel"].AsInteger (); }
/// <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(); }
/// <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); }
/// <summary> /// Query the given host (by connection) and verify that we can connect to it. /// </summary> /// <param name="connector">The host to connect to</param> /// <returns>The connection that has been recieved from the host</returns> public IWCConnection QueryRemoteHost (IWCConnection connection) { OSDMap request = connection.ToOSD(false); request["Method"] = "Query"; OSDMap reply = WebUtils.PostToService (connection.RecieverURL, request, true, true); if (reply["Success"].AsBoolean()) { if (reply["_Result"].Type != OSDType.Map) { m_log.Warn ("[IWC]: Unable to connect successfully to " + connection.RecieverURL + ", connection did not have all the required data."); return null; } OSDMap innerReply = (OSDMap)reply["_Result"]; if (innerReply["Result"].AsString() == "Successful") { IWCConnection c = new IWCConnection (); c.FromOSD(innerReply); IWCCertificate cert = new IWCCertificate (); cert.Connection = new IWCConnection (); cert.Active = true; cert.Connection.SenderURL = c.SenderURL; cert.Connection.RecieverURL = c.RecieverURL; cert.Connection.UserName = c.UserName; cert.Connection.Password = c.Password; cert.Connection.SecureUrls = c.SecureUrls; m_log.Error ("[IWC]: Connected successfully to " + connection.RecieverURL); return c; } m_log.Warn ("[IWC]: Unable to connect successfully to " + connection.RecieverURL + ", " + innerReply["Result"]); } else { m_log.Warn ("[IWC]: Unable to connect successfully to " + connection.RecieverURL); } return null; }