public bool VerifyClient(UUID sessionID, string reportedIP) { if (m_BypassClientVerification) { return(true); } m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", sessionID, reportedIP); HGTravelingData hgt = m_Database.Get(sessionID); if (hgt == null) { return(false); } TravelingAgentInfo travel = new TravelingAgentInfo(hgt); bool result = travel.ClientIPAddress == reportedIP; if (!result && !string.IsNullOrEmpty(m_MyExternalIP)) { result = reportedIP == m_MyExternalIP; // NATed } m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {2}; result is {3}", reportedIP, travel.ClientIPAddress, m_MyExternalIP, result); return(result); }
TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion region, bool fromLogin, out TravelingAgentInfo existing) { HGTravelingData hgt = m_Database.Get(agentCircuit.SessionID); existing = null; if (hgt != null) { // Very important! Override whatever this agent comes with. // UserAgentService always sets the IP for every new agent // with the original IP address. existing = new TravelingAgentInfo(hgt); agentCircuit.IPAddress = existing.ClientIPAddress; } TravelingAgentInfo travel = new TravelingAgentInfo(existing); travel.SessionID = agentCircuit.SessionID; travel.UserID = agentCircuit.AgentID; travel.GridExternalName = region.ServerURI; travel.ServiceToken = agentCircuit.ServiceSessionID; if (fromLogin) { travel.ClientIPAddress = agentCircuit.IPAddress; } StoreTravelInfo(travel); return(travel); }
public string ClientIPAddress = string.Empty; // as seen from this user agent service public TravelingAgentInfo(HGTravelingData t) { if (t.Data != null) { SessionID = new UUID(t.SessionID); UserID = new UUID(t.UserID); GridExternalName = t.Data["GridExternalName"]; ServiceToken = t.Data["ServiceToken"]; ClientIPAddress = t.Data["ClientIPAddress"]; } }
// We need to prevent foreign users with the same UUID as a local user public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) { HGTravelingData hgt = m_Database.Get(sessionID); if (hgt == null) { return(false); } TravelingAgentInfo travel = new TravelingAgentInfo(hgt); return(travel.GridExternalName.ToLower() == thisGridExternalName.ToLower()); }
public bool VerifyAgent(UUID sessionID, string token) { HGTravelingData hgt = m_Database.Get(sessionID); if (hgt == null) { m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID); return(false); } TravelingAgentInfo travel = new TravelingAgentInfo(hgt); m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, travel.ServiceToken); return(travel.ServiceToken == token); }
private void StoreTravelInfo(TravelingAgentInfo travel) { if (travel == null) { return; } HGTravelingData hgt = new HGTravelingData(); hgt.SessionID = travel.SessionID; hgt.UserID = travel.UserID; hgt.Data = new Dictionary <string, string>(); hgt.Data["GridExternalName"] = travel.GridExternalName; hgt.Data["ServiceToken"] = travel.ServiceToken; hgt.Data["ClientIPAddress"] = travel.ClientIPAddress; m_Database.Store(hgt); }