aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-12-08 22:00:59 +0000
committerJustin Clark-Casey (justincc)2011-12-08 22:00:59 +0000
commit50eebb5cba3bc4143115fca0e163ebdf3fc4dc60 (patch)
treec513f15dd42abd010bc3a872905971acfb3b1dd2
parentExtend TestAddClient() to check that the first packet received is an ack packet (diff)
downloadopensim-SC-50eebb5cba3bc4143115fca0e163ebdf3fc4dc60.zip
opensim-SC-50eebb5cba3bc4143115fca0e163ebdf3fc4dc60.tar.gz
opensim-SC-50eebb5cba3bc4143115fca0e163ebdf3fc4dc60.tar.bz2
opensim-SC-50eebb5cba3bc4143115fca0e163ebdf3fc4dc60.tar.xz
Don't reply with an ack packet if the client is not authorized.
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs71
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs5
2 files changed, 31 insertions, 45 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index cef5f74..5610c09 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -905,23 +905,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP
905// DateTime startTime = DateTime.Now; 905// DateTime startTime = DateTime.Now;
906 object[] array = (object[])o; 906 object[] array = (object[])o;
907 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; 907 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
908 UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; 908 UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
909 909
910 m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint); 910 m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint);
911 911
912 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; 912 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
913 913
914 // Begin the process of adding the client to the simulator 914 AuthenticateResponse sessionInfo;
915 IClientAPI client = AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); 915 if (IsClientAuthorized(uccp, out sessionInfo))
916 916 {
917 // Send ack straight away to let the viewer know that the connection is active. 917 // Begin the process of adding the client to the simulator
918 // The client will be null if it already exists (e.g. if on a region crossing the client sends a use 918 IClientAPI client
919 // circuit code to the existing child agent. This is not particularly obvious. 919 = AddClient(
920 SendAckImmediate(remoteEndPoint, packet.Header.Sequence); 920 uccp.CircuitCode.Code,
921 921 uccp.CircuitCode.ID,
922 // We only want to send initial data to new clients, not ones which are being converted from child to root. 922 uccp.CircuitCode.SessionID,
923 if (client != null) 923 remoteEndPoint,
924 client.SceneAgent.SendInitialDataToMe(); 924 sessionInfo);
925
926 // Send ack straight away to let the viewer know that the connection is active.
927 // The client will be null if it already exists (e.g. if on a region crossing the client sends a use
928 // circuit code to the existing child agent. This is not particularly obvious.
929 SendAckImmediate(remoteEndPoint, uccp.Header.Sequence);
930
931 // We only want to send initial data to new clients, not ones which are being converted from child to root.
932 if (client != null)
933 client.SceneAgent.SendInitialDataToMe();
934 }
935 else
936 {
937 // Don't create clients for unauthorized requesters.
938 m_log.WarnFormat(
939 "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
940 uccp.CircuitCode.ID, uccp.CircuitCode.Code, remoteEndPoint);
941 }
925 942
926 // m_log.DebugFormat( 943 // m_log.DebugFormat(
927// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", 944// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
@@ -972,36 +989,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
972 } 989 }
973 990
974 /// <summary> 991 /// <summary>
975 /// Add a new client.
976 /// </summary>
977 /// <param name="useCircuitCode"></param>
978 /// <param name="remoteEndPoint"></param>
979 /// <returns>
980 /// The client that was added or null if the client failed authorization or already existed.
981 /// </returns>
982 private IClientAPI AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
983 {
984 UUID agentID = useCircuitCode.CircuitCode.ID;
985 UUID sessionID = useCircuitCode.CircuitCode.SessionID;
986 uint circuitCode = useCircuitCode.CircuitCode.Code;
987
988 AuthenticateResponse sessionInfo;
989 if (IsClientAuthorized(useCircuitCode, out sessionInfo))
990 {
991 return AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
992 }
993 else
994 {
995 // Don't create circuits for unauthorized clients
996 m_log.WarnFormat(
997 "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
998 useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint);
999
1000 return null;
1001 }
1002 }
1003
1004 /// <summary>
1005 /// Add a client. 992 /// Add a client.
1006 /// </summary> 993 /// </summary>
1007 /// <param name="circuitCode"></param> 994 /// <param name="circuitCode"></param>
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
index 1457194..a575e36 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
@@ -202,10 +202,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
202 ScenePresence sp = scene.GetScenePresence(myAgentUuid); 202 ScenePresence sp = scene.GetScenePresence(myAgentUuid);
203 Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); 203 Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));
204 204
205 // FIXME: We're still replying to an ack when the client is not authorized, which is not correct behaviour. 205 Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(1));
206 Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(2));
207 206
208 Packet packet = llUdpServer.PacketsSent[1]; 207 Packet packet = llUdpServer.PacketsSent[0];
209 Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); 208 Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket)));
210 209
211 PacketAckPacket ackPacket = packet as PacketAckPacket; 210 PacketAckPacket ackPacket = packet as PacketAckPacket;