version 2.13.2
This commit is contained in:
@@ -63,12 +63,23 @@ QString preparePath(QString path)
|
||||
int whatIpVersion(QString ipAddress)
|
||||
{
|
||||
QStringList fieldList;
|
||||
ulong field;
|
||||
uint i;
|
||||
// ulong field;
|
||||
// uint i;
|
||||
uint ipversion;
|
||||
QHostAddress serverAddress;
|
||||
|
||||
info(DEBUGMACRO, "ipVersion of server at " + ipAddress);
|
||||
|
||||
fieldList = ipAddress.split(":");
|
||||
if (!serverAddress.setAddress(ipAddress))
|
||||
{
|
||||
error ("Address " + ipAddress + " is bad");
|
||||
}
|
||||
ipversion = serverAddress.protocol();
|
||||
|
||||
return (ipversion==IPV4?4:6);
|
||||
|
||||
|
||||
/*fieldList = ipAddress.split(":");
|
||||
if (fieldList.count() == 8)
|
||||
{
|
||||
for (i=0;i<8;i++)
|
||||
@@ -95,15 +106,14 @@ int whatIpVersion(QString ipAddress)
|
||||
}
|
||||
info(DEBUGMACRO, "Address is ip V4");
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
QHostAddress searchHosts(QString server)
|
||||
{
|
||||
QString line = "";
|
||||
QStringList hosts;
|
||||
QFile fileHandle;
|
||||
QFile fileHandle("/etc/hosts");
|
||||
QHostAddress serverAddress;
|
||||
|
||||
info(DEBUGMACRO, "reading /etc/hosts");
|
||||
@@ -117,16 +127,20 @@ QHostAddress searchHosts(QString server)
|
||||
while(!in.atEnd())
|
||||
{
|
||||
line = in.readLine();
|
||||
hosts = line.split(' ');
|
||||
hosts = line.split(QRegularExpression("\\s+"));
|
||||
if (hosts.contains(server))
|
||||
{
|
||||
if (!serverAddress.isNull() and serverAddress.protocol() == QAbstractSocket::IPv4Protocol)
|
||||
{
|
||||
serverAddress.setAddress(hosts.first());
|
||||
}
|
||||
//if (!serverAddress.isNull()) // and serverAddress.protocol() == QAbstractSocket::IPv4Protocol)
|
||||
//{
|
||||
if (!serverAddress.setAddress(hosts.first()))
|
||||
{
|
||||
error("Error setting address " + hosts.first());
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
void warning(QString message)
|
||||
|
||||
Reference in New Issue
Block a user