diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/NetworkUtil.cs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index 81e6cad..f9d9b89 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs | |||
@@ -3,6 +3,8 @@ using System.Collections.Generic; | |||
3 | using System.Net.Sockets; | 3 | using System.Net.Sockets; |
4 | using System.Net; | 4 | using System.Net; |
5 | using System.Net.NetworkInformation; | 5 | using System.Net.NetworkInformation; |
6 | using System.Reflection; | ||
7 | using log4net; | ||
6 | 8 | ||
7 | namespace OpenSim.Framework | 9 | namespace OpenSim.Framework |
8 | { | 10 | { |
@@ -16,6 +18,9 @@ namespace OpenSim.Framework | |||
16 | /// </summary> | 18 | /// </summary> |
17 | public static class NetworkUtil | 19 | public static class NetworkUtil |
18 | { | 20 | { |
21 | // Logger | ||
22 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
23 | |||
19 | // IPv4Address, Subnet | 24 | // IPv4Address, Subnet |
20 | static readonly Dictionary<IPAddress,IPAddress> m_subnets = new Dictionary<IPAddress, IPAddress>(); | 25 | static readonly Dictionary<IPAddress,IPAddress> m_subnets = new Dictionary<IPAddress, IPAddress>(); |
21 | 26 | ||
@@ -25,7 +30,10 @@ namespace OpenSim.Framework | |||
25 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) | 30 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) |
26 | { | 31 | { |
27 | if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork) | 32 | if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork) |
33 | { | ||
34 | m_log.Info("[NATROUTING] Localhost user detected, sending them '" + host + "' instead of '" + simulator + "'"); | ||
28 | return host; | 35 | return host; |
36 | } | ||
29 | } | 37 | } |
30 | 38 | ||
31 | // Check for same LAN segment | 39 | // Check for same LAN segment |
@@ -50,7 +58,10 @@ namespace OpenSim.Framework | |||
50 | } | 58 | } |
51 | 59 | ||
52 | if (valid) | 60 | if (valid) |
61 | { | ||
62 | m_log.Info("[NATROUTING] Local LAN user detected, sending them '" + subnet.Key + "' instead of '" + simulator + "'"); | ||
53 | return subnet.Key; | 63 | return subnet.Key; |
64 | } | ||
54 | } | 65 | } |
55 | 66 | ||
56 | // Otherwise, return outside address | 67 | // Otherwise, return outside address |
@@ -65,7 +76,10 @@ namespace OpenSim.Framework | |||
65 | foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname)) | 76 | foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname)) |
66 | { | 77 | { |
67 | if (host.AddressFamily == AddressFamily.InterNetworkV6) | 78 | if (host.AddressFamily == AddressFamily.InterNetworkV6) |
79 | { | ||
80 | m_log.Info("[NATROUTING] Localhost user detected, sending them '" + host + "' instead of '" + defaultHostname + "'"); | ||
68 | return host; | 81 | return host; |
82 | } | ||
69 | } | 83 | } |
70 | } | 84 | } |
71 | 85 | ||
@@ -101,7 +115,10 @@ namespace OpenSim.Framework | |||
101 | } | 115 | } |
102 | 116 | ||
103 | if (valid) | 117 | if (valid) |
118 | { | ||
119 | m_log.Info("[NATROUTING] Local LAN user detected, sending them '" + subnet.Key + "' instead of '" + defaultHostname + "'"); | ||
104 | return subnet.Key; | 120 | return subnet.Key; |
121 | } | ||
105 | } | 122 | } |
106 | 123 | ||
107 | // Check to see if we can find a IPv4 address. | 124 | // Check to see if we can find a IPv4 address. |
@@ -123,7 +140,13 @@ namespace OpenSim.Framework | |||
123 | { | 140 | { |
124 | if (address.Address.AddressFamily == AddressFamily.InterNetwork) | 141 | if (address.Address.AddressFamily == AddressFamily.InterNetwork) |
125 | { | 142 | { |
126 | m_subnets.Add(address.Address, address.IPv4Mask); | 143 | if (address.IPv4Mask != null) |
144 | { | ||
145 | m_subnets.Add(address.Address, address.IPv4Mask); | ||
146 | } else | ||
147 | { | ||
148 | m_log.Warn("[NetworkUtil] Found IPv4 Address without Subnet Mask!?"); | ||
149 | } | ||
127 | } | 150 | } |
128 | } | 151 | } |
129 | } | 152 | } |