aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Login
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Server/Handlers/Login
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Server/Handlers/Login')
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginHandlers.cs67
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs25
2 files changed, 89 insertions, 3 deletions
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
index f83a239..f2a5678 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Server.Handlers.Login
53 53
54 private ILoginService m_LocalService; 54 private ILoginService m_LocalService;
55 private bool m_Proxy; 55 private bool m_Proxy;
56
56 57
57 public LLLoginHandlers(ILoginService service, bool hasProxy) 58 public LLLoginHandlers(ILoginService service, bool hasProxy)
58 { 59 {
@@ -144,6 +145,17 @@ namespace OpenSim.Server.Handlers.Login
144 return FailedXMLRPCResponse(); 145 return FailedXMLRPCResponse();
145 146
146 } 147 }
148 public XmlRpcResponse HandleXMLRPCLoginBlocked(XmlRpcRequest request, IPEndPoint client)
149 {
150 XmlRpcResponse response = new XmlRpcResponse();
151 Hashtable resp = new Hashtable();
152
153 resp["reason"] = "presence";
154 resp["message"] = "Logins are currently restricted. Please try again later.";
155 resp["login"] = "false";
156 response.Value = resp;
157 return response;
158 }
147 159
148 public XmlRpcResponse HandleXMLRPCSetLoginLevel(XmlRpcRequest request, IPEndPoint remoteClient) 160 public XmlRpcResponse HandleXMLRPCSetLoginLevel(XmlRpcRequest request, IPEndPoint remoteClient)
149 { 161 {
@@ -213,6 +225,61 @@ namespace OpenSim.Server.Handlers.Login
213 return FailedOSDResponse(); 225 return FailedOSDResponse();
214 } 226 }
215 227
228 public void HandleWebSocketLoginEvents(string path, WebSocketHttpServerHandler sock)
229 {
230 sock.MaxPayloadSize = 16384; //16 kb payload
231 sock.InitialMsgTimeout = 5000; //5 second first message to trigger at least one of these events
232 sock.NoDelay_TCP_Nagle = true;
233 sock.OnData += delegate(object sender, WebsocketDataEventArgs data) { sock.Close("fail"); };
234 sock.OnPing += delegate(object sender, PingEventArgs pingdata) { sock.Close("fail"); };
235 sock.OnPong += delegate(object sender, PongEventArgs pongdata) { sock.Close("fail"); };
236 sock.OnText += delegate(object sender, WebsocketTextEventArgs text)
237 {
238 OSD request = null;
239 try
240 {
241 request = OSDParser.DeserializeJson(text.Data);
242 if (!(request is OSDMap))
243 {
244 sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse()));
245 }
246 else
247 {
248 OSDMap req = request as OSDMap;
249 string first = req["firstname"].AsString();
250 string last = req["lastname"].AsString();
251 string passwd = req["passwd"].AsString();
252 string start = req["startlocation"].AsString();
253 string version = req["version"].AsString();
254 string channel = req["channel"].AsString();
255 string mac = req["mac"].AsString();
256 string id0 = req["id0"].AsString();
257 UUID scope = UUID.Zero;
258 IPEndPoint endPoint =
259 (sender as WebSocketHttpServerHandler).GetRemoteIPEndpoint();
260 LoginResponse reply = null;
261 reply = m_LocalService.Login(first, last, passwd, start, scope, version,
262 channel, mac, id0, endPoint);
263 sock.SendMessage(OSDParser.SerializeJsonString(reply.ToOSDMap()));
264
265 }
266
267 }
268 catch (Exception)
269 {
270 sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse()));
271 }
272 finally
273 {
274 sock.Close("success");
275 }
276 };
277
278 sock.HandshakeAndUpgrade();
279
280 }
281
282
216 private XmlRpcResponse FailedXMLRPCResponse() 283 private XmlRpcResponse FailedXMLRPCResponse()
217 { 284 {
218 Hashtable hash = new Hashtable(); 285 Hashtable hash = new Hashtable();
diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
index 9a7ad34..f60e892 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
@@ -44,6 +44,7 @@ namespace OpenSim.Server.Handlers.Login
44 44
45 private ILoginService m_LoginService; 45 private ILoginService m_LoginService;
46 private bool m_Proxy; 46 private bool m_Proxy;
47 private BasicDosProtectorOptions m_DosProtectionOptions;
47 48
48 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : 49 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
49 base(config, server, String.Empty) 50 base(config, server, String.Empty)
@@ -60,8 +61,8 @@ namespace OpenSim.Server.Handlers.Login
60 InitializeHandlers(server); 61 InitializeHandlers(server);
61 } 62 }
62 63
63 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server) : 64 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, string configName) :
64 base(config, server, String.Empty) 65 base(config, server, configName)
65 { 66 {
66 string loginService = ReadLocalServiceFromConfig(config); 67 string loginService = ReadLocalServiceFromConfig(config);
67 68
@@ -72,6 +73,11 @@ namespace OpenSim.Server.Handlers.Login
72 InitializeHandlers(server); 73 InitializeHandlers(server);
73 } 74 }
74 75
76 public LLLoginServiceInConnector(IConfigSource config, IHttpServer server) :
77 this(config, server, String.Empty)
78 {
79 }
80
75 private string ReadLocalServiceFromConfig(IConfigSource config) 81 private string ReadLocalServiceFromConfig(IConfigSource config)
76 { 82 {
77 IConfig serverConfig = config.Configs["LoginService"]; 83 IConfig serverConfig = config.Configs["LoginService"];
@@ -83,6 +89,16 @@ namespace OpenSim.Server.Handlers.Login
83 throw new Exception(String.Format("No LocalServiceModule for LoginService in config file")); 89 throw new Exception(String.Format("No LocalServiceModule for LoginService in config file"));
84 90
85 m_Proxy = serverConfig.GetBoolean("HasProxy", false); 91 m_Proxy = serverConfig.GetBoolean("HasProxy", false);
92 m_DosProtectionOptions = new BasicDosProtectorOptions();
93 // Dos Protection Options
94 m_DosProtectionOptions.AllowXForwardedFor = serverConfig.GetBoolean("DOSAllowXForwardedForHeader", false);
95 m_DosProtectionOptions.RequestTimeSpan =
96 TimeSpan.FromMilliseconds(serverConfig.GetInt("DOSRequestTimeFrameMS", 10000));
97 m_DosProtectionOptions.MaxRequestsInTimeframe = serverConfig.GetInt("DOSMaxRequestsInTimeFrame", 5);
98 m_DosProtectionOptions.ForgetTimeSpan =
99 TimeSpan.FromMilliseconds(serverConfig.GetInt("DOSForgiveClientAfterMS", 120000));
100 m_DosProtectionOptions.ReportingName = "LOGINDOSPROTECTION";
101
86 102
87 return loginService; 103 return loginService;
88 } 104 }
@@ -90,9 +106,12 @@ namespace OpenSim.Server.Handlers.Login
90 private void InitializeHandlers(IHttpServer server) 106 private void InitializeHandlers(IHttpServer server)
91 { 107 {
92 LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService, m_Proxy); 108 LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService, m_Proxy);
93 server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); 109 server.AddXmlRPCHandler("login_to_simulator",
110 new XmlRpcBasicDOSProtector(loginHandlers.HandleXMLRPCLogin,loginHandlers.HandleXMLRPCLoginBlocked,
111 m_DosProtectionOptions).Process, false);
94 server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false); 112 server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false);
95 server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); 113 server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin);
114 server.AddWebSocketHandler("/WebSocket/GridLogin", loginHandlers.HandleWebSocketLoginEvents);
96 } 115 }
97 } 116 }
98} 117}