diff options
author | Melanie | 2011-05-08 20:23:06 +0100 |
---|---|---|
committer | Melanie | 2011-05-08 20:23:06 +0100 |
commit | b451cc1ebb9e950bb93e790ab9e83aff30a47c61 (patch) | |
tree | c9fbe41be36cf791976f9e5afabd44f69b64e747 /OpenSim/Framework/RegionInfo.cs | |
parent | Enable compressed (gzip) fatpack transfers. (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.zip opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.gz opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.bz2 opensim-SC-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Framework/RegionInfo.cs')
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 245 |
1 files changed, 0 insertions, 245 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index f05e2e6..17184d6 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -97,251 +97,6 @@ namespace OpenSim.Framework | |||
97 | 97 | ||
98 | } | 98 | } |
99 | 99 | ||
100 | [Serializable] | ||
101 | public class SimpleRegionInfo | ||
102 | { | ||
103 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
104 | |||
105 | /// <summary> | ||
106 | /// The port by which http communication occurs with the region (most noticeably, CAPS communication) | ||
107 | /// </summary> | ||
108 | public uint HttpPort | ||
109 | { | ||
110 | get { return m_httpPort; } | ||
111 | set { m_httpPort = value; } | ||
112 | } | ||
113 | protected uint m_httpPort; | ||
114 | |||
115 | /// <summary> | ||
116 | /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) | ||
117 | /// </summary> | ||
118 | public string ServerURI | ||
119 | { | ||
120 | get { | ||
121 | if ( m_serverURI != string.Empty ) { | ||
122 | return m_serverURI; | ||
123 | } else { | ||
124 | return "http://" + m_externalHostName + ":" + m_httpPort + "/"; | ||
125 | } | ||
126 | } | ||
127 | set { | ||
128 | if ( value.EndsWith("/") ) { | ||
129 | m_serverURI = value; | ||
130 | } else { | ||
131 | m_serverURI = value + '/'; | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | protected string m_serverURI; | ||
136 | |||
137 | public string RegionName | ||
138 | { | ||
139 | get { return m_regionName; } | ||
140 | set { m_regionName = value; } | ||
141 | } | ||
142 | protected string m_regionName = String.Empty; | ||
143 | |||
144 | protected bool Allow_Alternate_Ports; | ||
145 | public bool m_allow_alternate_ports; | ||
146 | protected string m_externalHostName; | ||
147 | |||
148 | protected IPEndPoint m_internalEndPoint; | ||
149 | protected uint? m_regionLocX; | ||
150 | protected uint? m_regionLocY; | ||
151 | protected uint m_remotingPort; | ||
152 | public UUID RegionID = UUID.Zero; | ||
153 | public string RemotingAddress; | ||
154 | public UUID ScopeID = UUID.Zero; | ||
155 | |||
156 | public SimpleRegionInfo() | ||
157 | { | ||
158 | m_serverURI = string.Empty; | ||
159 | } | ||
160 | |||
161 | public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) | ||
162 | { | ||
163 | m_regionLocX = regionLocX; | ||
164 | m_regionLocY = regionLocY; | ||
165 | |||
166 | m_internalEndPoint = internalEndPoint; | ||
167 | m_externalHostName = externalUri; | ||
168 | m_serverURI = string.Empty; | ||
169 | } | ||
170 | |||
171 | public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, uint port) | ||
172 | { | ||
173 | m_regionLocX = regionLocX; | ||
174 | m_regionLocY = regionLocY; | ||
175 | |||
176 | m_externalHostName = externalUri; | ||
177 | |||
178 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) port); | ||
179 | m_serverURI = string.Empty; | ||
180 | } | ||
181 | |||
182 | public SimpleRegionInfo(RegionInfo ConvertFrom) | ||
183 | { | ||
184 | m_regionName = ConvertFrom.RegionName; | ||
185 | m_regionLocX = ConvertFrom.RegionLocX; | ||
186 | m_regionLocY = ConvertFrom.RegionLocY; | ||
187 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | ||
188 | m_externalHostName = ConvertFrom.ExternalHostName; | ||
189 | m_remotingPort = ConvertFrom.RemotingPort; | ||
190 | m_httpPort = ConvertFrom.HttpPort; | ||
191 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
192 | RemotingAddress = ConvertFrom.RemotingAddress; | ||
193 | RegionID = UUID.Zero; | ||
194 | ServerURI = ConvertFrom.ServerURI; | ||
195 | } | ||
196 | |||
197 | public uint RemotingPort | ||
198 | { | ||
199 | get { return m_remotingPort; } | ||
200 | set { m_remotingPort = value; } | ||
201 | } | ||
202 | |||
203 | /// <value> | ||
204 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. | ||
205 | /// | ||
206 | /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? | ||
207 | /// </value> | ||
208 | public IPEndPoint ExternalEndPoint | ||
209 | { | ||
210 | get | ||
211 | { | ||
212 | // Old one defaults to IPv6 | ||
213 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); | ||
214 | |||
215 | IPAddress ia = null; | ||
216 | // If it is already an IP, don't resolve it - just return directly | ||
217 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
218 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
219 | |||
220 | // Reset for next check | ||
221 | ia = null; | ||
222 | try | ||
223 | { | ||
224 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
225 | { | ||
226 | if (ia == null) | ||
227 | ia = Adr; | ||
228 | |||
229 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
230 | { | ||
231 | ia = Adr; | ||
232 | break; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | catch (SocketException e) | ||
237 | { | ||
238 | throw new Exception( | ||
239 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
240 | e + "' attached to this exception", e); | ||
241 | } | ||
242 | |||
243 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
244 | } | ||
245 | |||
246 | set { m_externalHostName = value.ToString(); } | ||
247 | } | ||
248 | |||
249 | public string ExternalHostName | ||
250 | { | ||
251 | get { return m_externalHostName; } | ||
252 | set { m_externalHostName = value; } | ||
253 | } | ||
254 | |||
255 | public IPEndPoint InternalEndPoint | ||
256 | { | ||
257 | get { return m_internalEndPoint; } | ||
258 | set { m_internalEndPoint = value; } | ||
259 | } | ||
260 | |||
261 | public uint RegionLocX | ||
262 | { | ||
263 | get { return m_regionLocX.Value; } | ||
264 | set { m_regionLocX = value; } | ||
265 | } | ||
266 | |||
267 | public uint RegionLocY | ||
268 | { | ||
269 | get { return m_regionLocY.Value; } | ||
270 | set { m_regionLocY = value; } | ||
271 | } | ||
272 | |||
273 | public ulong RegionHandle | ||
274 | { | ||
275 | get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } | ||
276 | } | ||
277 | |||
278 | public int getInternalEndPointPort() | ||
279 | { | ||
280 | return m_internalEndPoint.Port; | ||
281 | } | ||
282 | |||
283 | public Dictionary<string, object> ToKeyValuePairs() | ||
284 | { | ||
285 | Dictionary<string, object> kvp = new Dictionary<string, object>(); | ||
286 | kvp["uuid"] = RegionID.ToString(); | ||
287 | kvp["locX"] = RegionLocX.ToString(); | ||
288 | kvp["locY"] = RegionLocY.ToString(); | ||
289 | kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); | ||
290 | kvp["external_port"] = ExternalEndPoint.Port.ToString(); | ||
291 | kvp["external_host_name"] = ExternalHostName; | ||
292 | kvp["http_port"] = HttpPort.ToString(); | ||
293 | kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); | ||
294 | kvp["internal_port"] = InternalEndPoint.Port.ToString(); | ||
295 | kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); | ||
296 | kvp["server_uri"] = ServerURI; | ||
297 | |||
298 | return kvp; | ||
299 | } | ||
300 | |||
301 | public SimpleRegionInfo(Dictionary<string, object> kvp) | ||
302 | { | ||
303 | if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) | ||
304 | { | ||
305 | int port = 0; | ||
306 | Int32.TryParse((string)kvp["external_port"], out port); | ||
307 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); | ||
308 | ExternalEndPoint = ep; | ||
309 | } | ||
310 | else | ||
311 | ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | ||
312 | |||
313 | if (kvp["external_host_name"] != null) | ||
314 | ExternalHostName = (string)kvp["external_host_name"]; | ||
315 | |||
316 | if (kvp["http_port"] != null) | ||
317 | { | ||
318 | UInt32 port = 0; | ||
319 | UInt32.TryParse((string)kvp["http_port"], out port); | ||
320 | HttpPort = port; | ||
321 | } | ||
322 | |||
323 | if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) | ||
324 | { | ||
325 | int port = 0; | ||
326 | Int32.TryParse((string)kvp["internal_port"], out port); | ||
327 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); | ||
328 | InternalEndPoint = ep; | ||
329 | } | ||
330 | else | ||
331 | InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | ||
332 | |||
333 | if (kvp["alternate_ports"] != null) | ||
334 | { | ||
335 | bool alts = false; | ||
336 | Boolean.TryParse((string)kvp["alternate_ports"], out alts); | ||
337 | m_allow_alternate_ports = alts; | ||
338 | } | ||
339 | |||
340 | if (kvp["server_uri"] != null) | ||
341 | ServerURI = (string)kvp["server_uri"]; | ||
342 | } | ||
343 | } | ||
344 | |||
345 | public class RegionInfo | 100 | public class RegionInfo |
346 | { | 101 | { |
347 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 102 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |