diff options
author | Justin Clarke Casey | 2008-11-25 15:19:00 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-25 15:19:00 +0000 |
commit | e187972377c19bdd85093677c4c54034e4f9196e (patch) | |
tree | cc1bb5f003628b018b823eafc9ee0a67f98df31c /OpenSim/Framework/HGNetworkServersInfo.cs | |
parent | * Adding some virtual hooks and making some privaets protected for great just... (diff) | |
download | opensim-SC-e187972377c19bdd85093677c4c54034e4f9196e.zip opensim-SC-e187972377c19bdd85093677c4c54034e4f9196e.tar.gz opensim-SC-e187972377c19bdd85093677c4c54034e4f9196e.tar.bz2 opensim-SC-e187972377c19bdd85093677c4c54034e4f9196e.tar.xz |
* Apply http://opensimulator.org/mantis/view.php?id=2640
* This is Diva's hypergrid patch, as perviously discussed on the opensim-dev mailing list
* Applied some minor prebuild.xml jiggling to resolve a dependency issue
* Thanks Diva!
Diffstat (limited to 'OpenSim/Framework/HGNetworkServersInfo.cs')
-rw-r--r-- | OpenSim/Framework/HGNetworkServersInfo.cs | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/OpenSim/Framework/HGNetworkServersInfo.cs b/OpenSim/Framework/HGNetworkServersInfo.cs new file mode 100644 index 0000000..5b19801 --- /dev/null +++ b/OpenSim/Framework/HGNetworkServersInfo.cs | |||
@@ -0,0 +1,90 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | |||
35 | namespace OpenSim.Framework | ||
36 | { | ||
37 | public class HGNetworkServersInfo | ||
38 | { | ||
39 | |||
40 | public readonly string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI; | ||
41 | |||
42 | private static HGNetworkServersInfo m_singleton; | ||
43 | public static HGNetworkServersInfo Singleton | ||
44 | { | ||
45 | get { return m_singleton; } | ||
46 | } | ||
47 | |||
48 | public static void Init(string assetserver, string inventoryserver, string userserver) | ||
49 | { | ||
50 | m_singleton = new HGNetworkServersInfo(assetserver, inventoryserver, userserver); | ||
51 | |||
52 | } | ||
53 | |||
54 | private HGNetworkServersInfo(string a, string i, string u) | ||
55 | { | ||
56 | LocalAssetServerURI = ServerURI(a); | ||
57 | LocalInventoryServerURI = ServerURI(i); | ||
58 | LocalUserServerURI = ServerURI(u); | ||
59 | } | ||
60 | |||
61 | public bool IsLocalUser(string userserver) | ||
62 | { | ||
63 | string userServerURI = ServerURI(userserver); | ||
64 | bool ret = (((userServerURI == null) || (userServerURI == "") || (userServerURI == LocalUserServerURI))); | ||
65 | //Console.WriteLine("-------------> HGNetworkServersInfo.IsLocalUser? " + ret + "(userServer=" + userServerURI + "; localuserserver=" + LocalUserServerURI + ")"); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | public static string ServerURI(string uri) | ||
70 | { | ||
71 | IPAddress ipaddr1 = null; | ||
72 | string port1 = ""; | ||
73 | try | ||
74 | { | ||
75 | ipaddr1 = Util.GetHostFromURL(uri); | ||
76 | } | ||
77 | catch { } | ||
78 | |||
79 | try | ||
80 | { | ||
81 | port1 = uri.Split(new char[] { ':' })[2]; | ||
82 | } | ||
83 | catch { } | ||
84 | |||
85 | // We tried our best to convert the domain names to IP addresses | ||
86 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; | ||
87 | } | ||
88 | |||
89 | } | ||
90 | } | ||