diff options
Diffstat (limited to 'OpenSim/Framework/NetworkUtil.cs')
-rw-r--r-- | OpenSim/Framework/NetworkUtil.cs | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index eeb514e..e3fb009 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs | |||
@@ -21,11 +21,22 @@ namespace OpenSim.Framework | |||
21 | // Logger | 21 | // Logger |
22 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 22 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
23 | 23 | ||
24 | private static bool m_disabled = true; | ||
25 | |||
26 | public static bool Enabled | ||
27 | { | ||
28 | set { m_disabled = value; } | ||
29 | get { return m_disabled; } | ||
30 | } | ||
31 | |||
24 | // IPv4Address, Subnet | 32 | // IPv4Address, Subnet |
25 | static readonly Dictionary<IPAddress,IPAddress> m_subnets = new Dictionary<IPAddress, IPAddress>(); | 33 | static readonly Dictionary<IPAddress,IPAddress> m_subnets = new Dictionary<IPAddress, IPAddress>(); |
26 | 34 | ||
27 | public static IPAddress GetIPFor(IPAddress user, IPAddress simulator) | 35 | public static IPAddress GetIPFor(IPAddress user, IPAddress simulator) |
28 | { | 36 | { |
37 | if(m_disabled) | ||
38 | return simulator; | ||
39 | |||
29 | // Check if we're accessing localhost. | 40 | // Check if we're accessing localhost. |
30 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) | 41 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) |
31 | { | 42 | { |
@@ -168,10 +179,13 @@ namespace OpenSim.Framework | |||
168 | 179 | ||
169 | public static IPAddress GetIPFor(IPEndPoint user, string defaultHostname) | 180 | public static IPAddress GetIPFor(IPEndPoint user, string defaultHostname) |
170 | { | 181 | { |
171 | // Try subnet matching | 182 | if (!m_disabled) |
172 | IPAddress rtn = GetExternalIPFor(user.Address, defaultHostname); | 183 | { |
173 | if (rtn != null) | 184 | // Try subnet matching |
174 | return rtn; | 185 | IPAddress rtn = GetExternalIPFor(user.Address, defaultHostname); |
186 | if (rtn != null) | ||
187 | return rtn; | ||
188 | } | ||
175 | 189 | ||
176 | // Otherwise use the old algorithm | 190 | // Otherwise use the old algorithm |
177 | IPAddress ia; | 191 | IPAddress ia; |
@@ -195,10 +209,12 @@ namespace OpenSim.Framework | |||
195 | 209 | ||
196 | public static string GetHostFor(IPAddress user, string defaultHostname) | 210 | public static string GetHostFor(IPAddress user, string defaultHostname) |
197 | { | 211 | { |
198 | IPAddress rtn = GetExternalIPFor(user, defaultHostname); | 212 | if (!m_disabled) |
199 | if(rtn != null) | 213 | { |
200 | return rtn.ToString(); | 214 | IPAddress rtn = GetExternalIPFor(user, defaultHostname); |
201 | 215 | if (rtn != null) | |
216 | return rtn.ToString(); | ||
217 | } | ||
202 | return defaultHostname; | 218 | return defaultHostname; |
203 | } | 219 | } |
204 | } | 220 | } |