diff options
Diffstat (limited to 'OpenSim/Framework/General')
-rw-r--r-- | OpenSim/Framework/General/Interfaces/IClientAPI.cs | 7 | ||||
-rw-r--r-- | OpenSim/Framework/General/Types/RegionInfo.cs | 270 |
2 files changed, 167 insertions, 110 deletions
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 4e8ac1a..ea4c5c9 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs | |||
@@ -32,6 +32,7 @@ using OpenSim.Framework.Inventory; | |||
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using libsecondlife.Packets; | 33 | using libsecondlife.Packets; |
34 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using System.Net; | ||
35 | 36 | ||
36 | namespace OpenSim.Framework.Interfaces | 37 | namespace OpenSim.Framework.Interfaces |
37 | { | 38 | { |
@@ -143,12 +144,12 @@ namespace OpenSim.Framework.Interfaces | |||
143 | void SendLayerData(float[] map); | 144 | void SendLayerData(float[] map); |
144 | void SendLayerData(int px, int py, float[] map); | 145 | void SendLayerData(int px, int py, float[] map); |
145 | void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look); | 146 | void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look); |
146 | void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort); | 147 | void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint ); |
147 | AgentCircuitData RequestClientInfo(); | 148 | AgentCircuitData RequestClientInfo(); |
148 | void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, System.Net.IPAddress newRegionIP, ushort newRegionPort); | 149 | void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint ); |
149 | void SendMapBlock(List<MapBlockData> mapBlocks); | 150 | void SendMapBlock(List<MapBlockData> mapBlocks); |
150 | void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags); | 151 | void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags); |
151 | void SendRegionTeleport(ulong regionHandle, byte simAccess, string ipAddress, ushort ipPort, uint locationID, uint flags); | 152 | void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags); |
152 | void SendTeleportCancel(); | 153 | void SendTeleportCancel(); |
153 | void SendTeleportLocationStart(); | 154 | void SendTeleportLocationStart(); |
154 | void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance); | 155 | void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance); |
diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs index 1ead3c4..d98dd60 100644 --- a/OpenSim/Framework/General/Types/RegionInfo.cs +++ b/OpenSim/Framework/General/Types/RegionInfo.cs | |||
@@ -33,6 +33,7 @@ using OpenSim.Framework.Interfaces; | |||
33 | using OpenSim.Framework.Utilities; | 33 | using OpenSim.Framework.Utilities; |
34 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
35 | using libsecondlife; | 35 | using libsecondlife; |
36 | using System.Net; | ||
36 | 37 | ||
37 | namespace OpenSim.Framework.Types | 38 | namespace OpenSim.Framework.Types |
38 | { | 39 | { |
@@ -41,6 +42,32 @@ namespace OpenSim.Framework.Types | |||
41 | public LLUUID SimUUID = new LLUUID(); | 42 | public LLUUID SimUUID = new LLUUID(); |
42 | public string RegionName = ""; | 43 | public string RegionName = ""; |
43 | 44 | ||
45 | private IPEndPoint m_internalEndPoint; | ||
46 | public IPEndPoint InternalEndPoint | ||
47 | { | ||
48 | get | ||
49 | { | ||
50 | return m_internalEndPoint; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | public IPEndPoint ExternalEndPoint | ||
55 | { | ||
56 | get | ||
57 | { | ||
58 | return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port ); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | private string m_externalHostName; | ||
63 | public string ExternalHostName | ||
64 | { | ||
65 | get | ||
66 | { | ||
67 | return m_externalHostName; | ||
68 | } | ||
69 | } | ||
70 | |||
44 | private uint? m_regionLocX; | 71 | private uint? m_regionLocX; |
45 | public uint RegionLocX | 72 | public uint RegionLocX |
46 | { | 73 | { |
@@ -81,43 +108,43 @@ namespace OpenSim.Framework.Types | |||
81 | public string MasterAvatarLastName = ""; | 108 | public string MasterAvatarLastName = ""; |
82 | public string MasterAvatarSandboxPassword = ""; | 109 | public string MasterAvatarSandboxPassword = ""; |
83 | 110 | ||
84 | private int? m_commsIPListenPort; | 111 | //private int? m_commsIPListenPort; |
85 | 112 | ||
86 | /// <summary> | 113 | ///// <summary> |
87 | /// Port used for listening (TCP and UDP) | 114 | ///// Port used for listening (TCP and UDP) |
88 | /// </summary> | 115 | ///// </summary> |
89 | /// <remarks>Seperate TCP and UDP</remarks> | 116 | ///// <remarks>Seperate TCP and UDP</remarks> |
90 | public int CommsIPListenPort | 117 | //public int CommsIPListenPort |
91 | { | 118 | //{ |
92 | get | 119 | // get |
93 | { | 120 | // { |
94 | return m_commsIPListenPort.Value; | 121 | // return m_commsIPListenPort.Value; |
95 | } | 122 | // } |
96 | } | 123 | //} |
97 | 124 | ||
98 | private string m_commsIPListenAddr; | 125 | //private string m_commsIPListenAddr; |
99 | /// <summary> | 126 | ///// <summary> |
100 | /// Address used for internal listening (default: 0.0.0.0?) | 127 | ///// Address used for internal listening (default: 0.0.0.0?) |
101 | /// </summary> | 128 | ///// </summary> |
102 | public string CommsIPListenAddr | 129 | //public string CommsIPListenAddr |
103 | { | 130 | //{ |
104 | get | 131 | // get |
105 | { | 132 | // { |
106 | return m_commsIPListenAddr; | 133 | // return m_commsIPListenAddr; |
107 | } | 134 | // } |
108 | } | 135 | //} |
109 | 136 | ||
110 | private string m_commsExternalAddress; | 137 | //private string m_commsExternalAddress; |
111 | /// <summary> | 138 | ///// <summary> |
112 | /// Address used for external addressing (DNS or IP) | 139 | ///// Address used for external addressing (DNS or IP) |
113 | /// </summary> | 140 | ///// </summary> |
114 | public string CommsExternalAddress | 141 | //public string CommsExternalAddress |
115 | { | 142 | //{ |
116 | get | 143 | // get |
117 | { | 144 | // { |
118 | return m_commsExternalAddress; | 145 | // return m_commsExternalAddress; |
119 | } | 146 | // } |
120 | } | 147 | //} |
121 | 148 | ||
122 | 149 | ||
123 | public EstateSettings estateSettings; | 150 | public EstateSettings estateSettings; |
@@ -126,15 +153,19 @@ namespace OpenSim.Framework.Types | |||
126 | { | 153 | { |
127 | estateSettings = new EstateSettings(); | 154 | estateSettings = new EstateSettings(); |
128 | } | 155 | } |
129 | 156 | ||
130 | public RegionInfo( uint regionLocX, uint regionLocY, string simIp, int simPort, string simUri ) : this() | 157 | public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) |
158 | : this() | ||
131 | { | 159 | { |
132 | m_regionLocX = regionLocX; | 160 | m_regionLocX = regionLocX; |
133 | m_regionLocY = regionLocY; | 161 | m_regionLocY = regionLocY; |
134 | 162 | ||
135 | m_commsIPListenAddr = simIp; | 163 | //m_commsIPListenAddr = simIp; |
136 | m_commsIPListenPort = simPort; | 164 | //m_commsIPListenPort = simPort; |
137 | m_commsExternalAddress = simUri; | 165 | //m_commsExternalAddress = simUri; |
166 | |||
167 | m_internalEndPoint = internalEndPoint; | ||
168 | m_externalHostName = externalUri; | ||
138 | } | 169 | } |
139 | 170 | ||
140 | public void InitConfig(bool sandboxMode, IGenericConfig configData) | 171 | public void InitConfig(bool sandboxMode, IGenericConfig configData) |
@@ -195,7 +226,7 @@ namespace OpenSim.Framework.Types | |||
195 | } | 226 | } |
196 | 227 | ||
197 | m_regionHandle = null; | 228 | m_regionHandle = null; |
198 | 229 | ||
199 | // Local storage datastore | 230 | // Local storage datastore |
200 | attri = ""; | 231 | attri = ""; |
201 | attri = configData.GetAttribute("Datastore"); | 232 | attri = configData.GetAttribute("Datastore"); |
@@ -210,71 +241,67 @@ namespace OpenSim.Framework.Types | |||
210 | this.DataStore = attri; | 241 | this.DataStore = attri; |
211 | } | 242 | } |
212 | 243 | ||
213 | //Sim Listen Port | 244 | IPAddress internalAddress = GetIPAddress(configData, "InternalIPAddress", "0.0.0.0", "Internal IP Address for UDP client connections"); |
214 | attri = ""; | 245 | int internalPort = GetIPPort(configData, "InternalIPPort", "9000", "Internal IP Port for UDP client connections"); |
215 | attri = configData.GetAttribute("SimListenPort"); | 246 | m_internalEndPoint = new IPEndPoint(internalAddress, internalPort); |
216 | if (attri == "") | 247 | |
217 | { | 248 | m_externalHostName = MainLog.Instance.CmdPrompt("External Host Name", "localhost"); |
218 | string port = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("UDP port for client connections", "9000"); | 249 | |
219 | configData.SetAttribute("SimListenPort", port); | 250 | |
220 | m_commsIPListenPort = Convert.ToInt32(port); | 251 | |
221 | } | 252 | |
222 | else | ||
223 | { | ||
224 | m_commsIPListenPort = Convert.ToInt32(attri); | ||
225 | } | ||
226 | 253 | ||
227 | //Sim Listen Address | 254 | //Sim Listen Address |
228 | attri = ""; | 255 | //attri = ""; |
229 | attri = configData.GetAttribute("SimListenAddress"); | 256 | //attri = configData.GetAttribute("SimListenAddress"); |
230 | if (attri == "") | 257 | //if (attri == "") |
231 | { | 258 | //{ |
232 | m_commsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0"); | 259 | // m_commsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0"); |
233 | configData.SetAttribute("SimListenAddress", CommsIPListenAddr ); | 260 | // configData.SetAttribute("SimListenAddress", CommsIPListenAddr); |
234 | } | 261 | //} |
235 | else | 262 | //else |
236 | { | 263 | //{ |
237 | // Probably belongs elsewhere, but oh well. | 264 | // // Probably belongs elsewhere, but oh well. |
238 | if (attri.Trim().StartsWith("SYSTEMIP")) | 265 | // if (attri.Trim().StartsWith("SYSTEMIP")) |
239 | { | 266 | // { |
240 | string localhostname = System.Net.Dns.GetHostName(); | 267 | // string localhostname = System.Net.Dns.GetHostName(); |
241 | System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname); | 268 | // System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname); |
242 | try | 269 | // try |
243 | { | 270 | // { |
244 | m_commsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found | 271 | // m_commsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found |
245 | |||
246 | foreach (System.Net.IPAddress ip in ips) | ||
247 | { | ||
248 | if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString()) | ||
249 | { | ||
250 | m_commsIPListenAddr = ip.ToString(); | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | catch (Exception) | ||
256 | { | ||
257 | m_commsIPListenAddr = "0.0.0.0"; // Use the default if we fail | ||
258 | } | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | m_commsIPListenAddr = attri; | ||
263 | } | ||
264 | } | ||
265 | 272 | ||
266 | // Sim External Address | 273 | // foreach (System.Net.IPAddress ip in ips) |
267 | attri = ""; | 274 | // { |
268 | attri = configData.GetAttribute("SimExternalAddress"); | 275 | // if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString()) |
269 | if (attri == "") | 276 | // { |
270 | { | 277 | // m_commsIPListenAddr = ip.ToString(); |
271 | m_commsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost"); | 278 | // break; |
272 | configData.SetAttribute("SimExternalAddress", CommsExternalAddress); | 279 | // } |
273 | } | 280 | // } |
274 | else | 281 | // } |
275 | { | 282 | // catch (Exception) |
276 | m_commsExternalAddress = attri; | 283 | // { |
277 | } | 284 | // m_commsIPListenAddr = "0.0.0.0"; // Use the default if we fail |
285 | // } | ||
286 | // } | ||
287 | // else | ||
288 | // { | ||
289 | // m_commsIPListenAddr = attri; | ||
290 | // } | ||
291 | //} | ||
292 | |||
293 | //// Sim External Address | ||
294 | //attri = ""; | ||
295 | //attri = configData.GetAttribute("SimExternalAddress"); | ||
296 | //if (attri == "") | ||
297 | //{ | ||
298 | // m_commsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost"); | ||
299 | // configData.SetAttribute("SimExternalAddress", CommsExternalAddress); | ||
300 | //} | ||
301 | //else | ||
302 | //{ | ||
303 | // m_commsExternalAddress = attri; | ||
304 | //} | ||
278 | 305 | ||
279 | attri = ""; | 306 | attri = ""; |
280 | attri = configData.GetAttribute("TerrainFile"); | 307 | attri = configData.GetAttribute("TerrainFile"); |
@@ -357,9 +384,38 @@ namespace OpenSim.Framework.Types | |||
357 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Name: " + this.RegionName); | 384 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Name: " + this.RegionName); |
358 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); | 385 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); |
359 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Handle: " + this.RegionHandle.ToString()); | 386 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Handle: " + this.RegionHandle.ToString()); |
360 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Listening on IP: " + this.CommsIPListenAddr + ":" + this.CommsIPListenPort); | 387 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Listening on IP end point: " + m_internalEndPoint.ToString() ); |
361 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Sandbox Mode? " + isSandbox.ToString()); | 388 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Sandbox Mode? " + isSandbox.ToString()); |
362 | 389 | ||
363 | } | 390 | } |
391 | |||
392 | private IPAddress GetIPAddress(IGenericConfig configData, string attrName, string defaultvalue, string prompt) | ||
393 | { | ||
394 | string addressStr = configData.GetAttribute(attrName); | ||
395 | |||
396 | IPAddress address; | ||
397 | |||
398 | if (!IPAddress.TryParse(addressStr, out address)) | ||
399 | { | ||
400 | address = MainLog.Instance.CmdPromptIPAddress(prompt, defaultvalue); | ||
401 | configData.SetAttribute(attrName, address.ToString()); | ||
402 | } | ||
403 | return address; | ||
404 | } | ||
405 | |||
406 | private int GetIPPort(IGenericConfig configData, string attrName, string defaultvalue, string prompt) | ||
407 | { | ||
408 | string portStr = configData.GetAttribute(attrName); | ||
409 | |||
410 | int port; | ||
411 | |||
412 | if (!int.TryParse(portStr, out port)) | ||
413 | { | ||
414 | port = MainLog.Instance.CmdPromptIPPort(prompt, defaultvalue); | ||
415 | configData.SetAttribute(attrName, port.ToString()); | ||
416 | } | ||
417 | |||
418 | return port; | ||
419 | } | ||
364 | } | 420 | } |
365 | } | 421 | } |