aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
authorMW2009-01-15 14:37:04 +0000
committerMW2009-01-15 14:37:04 +0000
commit940728dad707eb753b7254e53c2656c624ec8eb1 (patch)
tree8648aa8f44efc807cc17eae0675be6b3e394a30c /OpenSim/Region/Application
parentAdded a taint to the sculpt texture callback in an attempt to mitigate Mantis... (diff)
downloadopensim-SC_OLD-940728dad707eb753b7254e53c2656c624ec8eb1.zip
opensim-SC_OLD-940728dad707eb753b7254e53c2656c624ec8eb1.tar.gz
opensim-SC_OLD-940728dad707eb753b7254e53c2656c624ec8eb1.tar.bz2
opensim-SC_OLD-940728dad707eb753b7254e53c2656c624ec8eb1.tar.xz
Added initial support for reading hypergrid links from a xml config file. Although its currently still activated by using console command: link-region <URI of xml file> , the uri should be able to be a local file path or a http uri. I'm adding details of the format of the xml file to the wiki's hypergrid page.
TODO: Add a initial startup option for setting the uri and making it autoload it. Add support for scanning the xml file to check that its own region(s) aren't in the list, and if they are, ignoring them. This would allow setting up "virtual link/grid lists" on webservers, that people can add their own regions to and also point those regions to those same lists, so they load the other region's data. Add support for automapping of those region/link lists.
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r--OpenSim/Region/Application/HGOpenSimNode.cs115
1 files changed, 84 insertions, 31 deletions
diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs
index 6c2db82..11bdbbc 100644
--- a/OpenSim/Region/Application/HGOpenSimNode.cs
+++ b/OpenSim/Region/Application/HGOpenSimNode.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Net; 32using System.Net;
33using System.Reflection; 33using System.Reflection;
34using System.Xml;
34using log4net; 35using log4net;
35using Nini.Config; 36using Nini.Config;
36using OpenSim.Framework; 37using OpenSim.Framework;
@@ -144,18 +145,38 @@ namespace OpenSim
144 // link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> 145 // link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName>
145 if (cmdparams.Length < 4) 146 if (cmdparams.Length < 4)
146 { 147 {
147 LinkRegionCmdUsage(); 148 if (cmdparams.Length == 1)
149 {
150 try
151 {
152 XmlReader r = XmlReader.Create(cmdparams[0]);
153 XmlConfigSource cs = new XmlConfigSource(r);
154 for (int i = 0; i < cs.Configs.Count; i++)
155 {
156 ReadLinkFromConfig(cs.Configs[i]);
157 }
158 }
159 catch (Exception)
160 {
161 }
162 }
163 else
164 {
165 LinkRegionCmdUsage();
166 }
148 return; 167 return;
149 } 168 }
150 169
151 RegionInfo regInfo = new RegionInfo(); 170 RegionInfo regInfo;
152 uint xloc, yloc; 171 uint xloc, yloc;
153 uint externalPort; 172 uint externalPort;
173 string externalHostName;
154 try 174 try
155 { 175 {
156 xloc = Convert.ToUInt32(cmdparams[0]); 176 xloc = Convert.ToUInt32(cmdparams[0]);
157 yloc = Convert.ToUInt32(cmdparams[1]); 177 yloc = Convert.ToUInt32(cmdparams[1]);
158 externalPort = Convert.ToUInt32(cmdparams[3]); 178 externalPort = Convert.ToUInt32(cmdparams[3]);
179 externalHostName = cmdparams[2];
159 //internalPort = Convert.ToUInt32(cmdparams[4]); 180 //internalPort = Convert.ToUInt32(cmdparams[4]);
160 //remotingPort = Convert.ToUInt32(cmdparams[5]); 181 //remotingPort = Convert.ToUInt32(cmdparams[5]);
161 } 182 }
@@ -165,44 +186,76 @@ namespace OpenSim
165 LinkRegionCmdUsage(); 186 LinkRegionCmdUsage();
166 return; 187 return;
167 } 188 }
168 regInfo.RegionLocX = xloc;
169 regInfo.RegionLocY = yloc;
170 regInfo.ExternalHostName = cmdparams[2];
171 regInfo.HttpPort = externalPort;
172 //regInfo.RemotingPort = remotingPort;
173 try
174 {
175 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
176 }
177 catch (Exception e)
178 {
179 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
180 LinkRegionCmdUsage();
181 return;
182 }
183 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
184 189
185 // Finally, link it 190 if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
186 try
187 { 191 {
188 m_sceneManager.CurrentOrFirstScene.CommsManager.GridService.RegisterRegion(regInfo); 192 if (cmdparams.Length >= 5)
189 } 193 {
190 catch (Exception e) 194 regInfo.RegionName = "";
191 { 195 for (int i = 4; i < cmdparams.Length; i++)
192 m_log.Warn("[HGrid] Unable to link region: " + e.StackTrace); 196 regInfo.RegionName += cmdparams[i] + " ";
193 } 197 }
194 if (cmdparams.Length >= 5)
195 {
196 regInfo.RegionName = "";
197 for (int i = 4; i < cmdparams.Length; i++)
198 regInfo.RegionName += cmdparams[i] + " ";
199 } 198 }
199
200 return;
200 } 201 }
201 202
202 base.RunCmd(command, cmdparams); 203 base.RunCmd(command, cmdparams);
203 204
204 } 205 }
205 206
207 private void ReadLinkFromConfig(IConfig config)
208 {
209 RegionInfo regInfo;
210 uint xloc, yloc;
211 uint externalPort;
212 string externalHostName;
213
214 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
215 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
216 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
217 externalHostName = config.GetString("externalHostName", "");
218
219 if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
220 {
221 regInfo.RegionName = config.GetString("localName", "");
222 }
223 }
224
225 private bool TryCreateLink(uint xloc, uint yloc, uint externalPort, string externalHostName, out RegionInfo regInfo)
226 {
227 regInfo = new RegionInfo();
228 regInfo.RegionLocX = xloc;
229 regInfo.RegionLocY = yloc;
230 regInfo.ExternalHostName = externalHostName;
231 regInfo.HttpPort = externalPort;
232 //regInfo.RemotingPort = remotingPort;
233 try
234 {
235 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
236 }
237 catch (Exception e)
238 {
239 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
240 LinkRegionCmdUsage();
241 return false;
242 }
243 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
244
245 // Finally, link it
246 try
247 {
248 m_sceneManager.CurrentOrFirstScene.CommsManager.GridService.RegisterRegion(regInfo);
249 }
250 catch (Exception e)
251 {
252 m_log.Warn("[HGrid] Unable to link region: " + e.StackTrace);
253 return false;
254 }
255
256 return true;
257 }
258
206 private void LinkRegionCmdUsage() 259 private void LinkRegionCmdUsage()
207 { 260 {
208 Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); 261 Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");