aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Console/LogBase.cs58
-rw-r--r--OpenSim/Framework/General/Interfaces/IClientAPI.cs7
-rw-r--r--OpenSim/Framework/General/Types/RegionInfo.cs270
3 files changed, 218 insertions, 117 deletions
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
index 1a92d8e..a4a17e9 100644
--- a/OpenSim/Framework/Console/LogBase.cs
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Net;
30 31
31namespace OpenSim.Framework.Console 32namespace OpenSim.Framework.Console
32{ 33{
@@ -48,18 +49,18 @@ namespace OpenSim.Framework.Console
48 public string componentname; 49 public string componentname;
49 private bool m_silent; 50 private bool m_silent;
50 51
51 public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent ) 52 public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent)
52 { 53 {
53 this.componentname = componentname; 54 this.componentname = componentname;
54 this.cmdparser = cmdparser; 55 this.cmdparser = cmdparser;
55 this.m_silent = silent; 56 this.m_silent = silent;
56 System.Console.WriteLine("ServerConsole.cs - creating new local console"); 57 System.Console.WriteLine("ServerConsole.cs - creating new local console");
57 58
58 if( String.IsNullOrEmpty( LogFile ) ) 59 if (String.IsNullOrEmpty(LogFile))
59 { 60 {
60 LogFile = componentname + ".log"; 61 LogFile = componentname + ".log";
61 } 62 }
62 63
63 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); 64 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
64 Log = File.AppendText(LogFile); 65 Log = File.AppendText(LogFile);
65 Log.WriteLine("========================================================================"); 66 Log.WriteLine("========================================================================");
@@ -74,10 +75,10 @@ namespace OpenSim.Framework.Console
74 75
75 public void Write(string format, params object[] args) 76 public void Write(string format, params object[] args)
76 { 77 {
77 Notice(format,args); 78 Notice(format, args);
78 return; 79 return;
79 } 80 }
80 81
81 public void WriteLine(LogPriority importance, string format, params object[] args) 82 public void WriteLine(LogPriority importance, string format, params object[] args)
82 { 83 {
83 Log.WriteLine(format, args); 84 Log.WriteLine(format, args);
@@ -154,6 +155,49 @@ namespace OpenSim.Framework.Console
154 return TempInt; 155 return TempInt;
155 } 156 }
156 157
158 public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
159 {
160 IPAddress address;
161 string addressStr;
162
163 while (true)
164 {
165 addressStr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt(prompt, defaultvalue);
166 if (IPAddress.TryParse(addressStr, out address))
167 {
168 break;
169 }
170 else
171 {
172 OpenSim.Framework.Console.MainLog.Instance.Error("Illegal address. Please re-enter.");
173 }
174 }
175
176 return address;
177 }
178
179 public int CmdPromptIPPort(string prompt, string defaultvalue)
180 {
181 int port;
182 string portStr;
183
184 while (true)
185 {
186 portStr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt(prompt, defaultvalue);
187 if (int.TryParse(portStr, out port))
188 {
189 if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
190 {
191 break;
192 }
193 }
194
195 OpenSim.Framework.Console.MainLog.Instance.Error("Illegal address. Please re-enter.");
196 }
197
198 return port;
199 }
200
157 // Displays a prompt and waits for the user to enter a string, then returns that string 201 // Displays a prompt and waits for the user to enter a string, then returns that string
158 // Done with no echo and suitable for passwords 202 // Done with no echo and suitable for passwords
159 public string PasswdPrompt(string prompt) 203 public string PasswdPrompt(string prompt)
@@ -178,7 +222,7 @@ namespace OpenSim.Framework.Console
178 // Displays a command prompt and returns a default value if the user simply presses enter 222 // Displays a command prompt and returns a default value if the user simply presses enter
179 public string CmdPrompt(string prompt, string defaultresponse) 223 public string CmdPrompt(string prompt, string defaultresponse)
180 { 224 {
181 string temp = CmdPrompt(String.Format( "{0} [{1}]", prompt, defaultresponse )); 225 string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
182 if (temp == "") 226 if (temp == "")
183 { 227 {
184 return defaultresponse; 228 return defaultresponse;
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;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using OpenSim.Framework.Types; 34using OpenSim.Framework.Types;
35using System.Net;
35 36
36namespace OpenSim.Framework.Interfaces 37namespace 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;
33using OpenSim.Framework.Utilities; 33using OpenSim.Framework.Utilities;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using libsecondlife; 35using libsecondlife;
36using System.Net;
36 37
37namespace OpenSim.Framework.Types 38namespace 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}