mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added checks to the NetBIOS name server config/startup to make sure the server has at least one valid local IP address.
Linux often defaults the local host name to the 127.0.0.1 address which causes problems with name lookups. (Fixes AR-422) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2361 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1481,6 +1481,21 @@ public class NetBIOSNameServer extends NetworkServer implements Runnable
|
|||||||
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
||||||
ipList.add(addrs[i].getAddress());
|
ipList.add(addrs[i].getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if any addresses were added to the list
|
||||||
|
|
||||||
|
if ( ipList.size() == 0)
|
||||||
|
{
|
||||||
|
// Log the available IP addresses
|
||||||
|
|
||||||
|
logger.error("Failed to get IP address(es) for NetBIOS name");
|
||||||
|
for ( int i = 0; i < addrs.length; i++)
|
||||||
|
logger.error( " Address: " + addrs[i]);
|
||||||
|
logger.error("Check hosts file and/or DNS setup");
|
||||||
|
logger.error("NetBIOS name server is shutting down");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the NetBIOS name socket
|
// Initialize the NetBIOS name socket
|
||||||
|
@@ -781,6 +781,64 @@ public class ServerConfiguration
|
|||||||
|
|
||||||
setNetBIOSBindAddress(getSMBBindAddress());
|
setNetBIOSBindAddress(getSMBBindAddress());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get a list of all the local addresses
|
||||||
|
|
||||||
|
InetAddress[] addrs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get the local server IP address list
|
||||||
|
|
||||||
|
addrs = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
|
||||||
|
}
|
||||||
|
catch (UnknownHostException ex)
|
||||||
|
{
|
||||||
|
logger.error("Failed to get local address list", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the address list for one or more valid local addresses filtering out the loopback address
|
||||||
|
|
||||||
|
int addrCnt = 0;
|
||||||
|
|
||||||
|
if ( addrs != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < addrs.length; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Check for a valid address, filter out '127.0.0.1' and '0.0.0.0' addresses
|
||||||
|
|
||||||
|
if (addrs[i].getHostAddress().equals("127.0.0.1") == false
|
||||||
|
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
|
||||||
|
addrCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if any addresses were found
|
||||||
|
|
||||||
|
if ( addrCnt == 0)
|
||||||
|
{
|
||||||
|
// Log the available IP addresses
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Local address list dump :-");
|
||||||
|
if ( addrs != null)
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < addrs.length; i++)
|
||||||
|
logger.debug( " Address: " + addrs[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.debug(" No addresses");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw an exception to stop the CIFS/NetBIOS name server from starting
|
||||||
|
|
||||||
|
throw new AlfrescoRuntimeException( "Failed to get IP address(es) for the local server, check hosts file and/or DNS setup");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user