diff options
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r-- | OpenSim/Region/Application/HGOpenSimNode.cs | 115 |
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; | |||
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Net; | 32 | using System.Net; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Xml; | ||
34 | using log4net; | 35 | using log4net; |
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenSim.Framework; | 37 | using 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>]"); |