diff options
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | 4 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs | 122 |
2 files changed, 126 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs index f03d33a..15b29d2 100644 --- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | |||
@@ -46,6 +46,10 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
46 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private IGatekeeperService m_GatekeeperService; | 48 | private IGatekeeperService m_GatekeeperService; |
49 | public IGatekeeperService GateKeeper | ||
50 | { | ||
51 | get { return m_GatekeeperService; } | ||
52 | } | ||
49 | 53 | ||
50 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : | 54 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : |
51 | base(config, server, String.Empty) | 55 | base(config, server, String.Empty) |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs new file mode 100644 index 0000000..5379784 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs | |||
@@ -0,0 +1,122 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | |||
7 | using Nini.Config; | ||
8 | using OpenSim.Framework; | ||
9 | using OpenSim.Server.Base; | ||
10 | using OpenSim.Services.Interfaces; | ||
11 | using OpenSim.Framework.Servers.HttpServer; | ||
12 | using OpenSim.Server.Handlers.Base; | ||
13 | |||
14 | using log4net; | ||
15 | using Nwc.XmlRpc; | ||
16 | using OpenMetaverse; | ||
17 | |||
18 | namespace OpenSim.Server.Handlers.Hypergrid | ||
19 | { | ||
20 | public class HomeUsersSecurityServerConnector : ServiceConnector | ||
21 | { | ||
22 | private static readonly ILog m_log = | ||
23 | LogManager.GetLogger( | ||
24 | MethodBase.GetCurrentMethod().DeclaringType); | ||
25 | |||
26 | private IHomeUsersSecurityService m_HomeUsersService; | ||
27 | |||
28 | public HomeUsersSecurityServerConnector(IConfigSource config, IHttpServer server) : | ||
29 | base(config, server, String.Empty) | ||
30 | { | ||
31 | IConfig gridConfig = config.Configs["HomeUsersSecurityService"]; | ||
32 | if (gridConfig != null) | ||
33 | { | ||
34 | string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); | ||
35 | Object[] args = new Object[] { config }; | ||
36 | m_HomeUsersService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(serviceDll, args); | ||
37 | } | ||
38 | if (m_HomeUsersService == null) | ||
39 | throw new Exception("HomeUsersSecurity server connector cannot proceed because of missing service"); | ||
40 | |||
41 | server.AddXmlRPCHandler("ep_get", GetEndPoint, false); | ||
42 | server.AddXmlRPCHandler("ep_set", SetEndPoint, false); | ||
43 | server.AddXmlRPCHandler("ep_remove", RemoveEndPoint, false); | ||
44 | |||
45 | } | ||
46 | |||
47 | public XmlRpcResponse GetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) | ||
48 | { | ||
49 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
50 | //string host = (string)requestData["host"]; | ||
51 | //string portstr = (string)requestData["port"]; | ||
52 | string sessionID_str = (string)requestData["sessionID"]; | ||
53 | UUID sessionID = UUID.Zero; | ||
54 | UUID.TryParse(sessionID_str, out sessionID); | ||
55 | |||
56 | IPEndPoint ep = m_HomeUsersService.GetEndPoint(sessionID); | ||
57 | |||
58 | Hashtable hash = new Hashtable(); | ||
59 | if (ep == null) | ||
60 | hash["result"] = "false"; | ||
61 | else | ||
62 | { | ||
63 | hash["result"] = "true"; | ||
64 | hash["ep_addr"] = ep.Address.ToString(); | ||
65 | hash["ep_port"] = ep.Port.ToString(); | ||
66 | } | ||
67 | XmlRpcResponse response = new XmlRpcResponse(); | ||
68 | response.Value = hash; | ||
69 | return response; | ||
70 | |||
71 | } | ||
72 | |||
73 | public XmlRpcResponse SetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) | ||
74 | { | ||
75 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
76 | string host = (string)requestData["ep_addr"]; | ||
77 | string portstr = (string)requestData["ep_port"]; | ||
78 | string sessionID_str = (string)requestData["sessionID"]; | ||
79 | UUID sessionID = UUID.Zero; | ||
80 | UUID.TryParse(sessionID_str, out sessionID); | ||
81 | int port = 0; | ||
82 | Int32.TryParse(portstr, out port); | ||
83 | |||
84 | IPEndPoint ep = null; | ||
85 | try | ||
86 | { | ||
87 | ep = new IPEndPoint(IPAddress.Parse(host), port); | ||
88 | } | ||
89 | catch | ||
90 | { | ||
91 | m_log.Debug("[HOME USERS SECURITY]: Exception in creating EndPoint"); | ||
92 | } | ||
93 | |||
94 | m_HomeUsersService.SetEndPoint(sessionID, ep); | ||
95 | |||
96 | Hashtable hash = new Hashtable(); | ||
97 | hash["result"] = "true"; | ||
98 | XmlRpcResponse response = new XmlRpcResponse(); | ||
99 | response.Value = hash; | ||
100 | return response; | ||
101 | |||
102 | } | ||
103 | |||
104 | public XmlRpcResponse RemoveEndPoint(XmlRpcRequest request, IPEndPoint remoteClient) | ||
105 | { | ||
106 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
107 | string sessionID_str = (string)requestData["sessionID"]; | ||
108 | UUID sessionID = UUID.Zero; | ||
109 | UUID.TryParse(sessionID_str, out sessionID); | ||
110 | |||
111 | m_HomeUsersService.RemoveEndPoint(sessionID); | ||
112 | |||
113 | Hashtable hash = new Hashtable(); | ||
114 | hash["result"] = "true"; | ||
115 | XmlRpcResponse response = new XmlRpcResponse(); | ||
116 | response.Value = hash; | ||
117 | return response; | ||
118 | |||
119 | } | ||
120 | |||
121 | } | ||
122 | } | ||