version 2.13.2

This commit is contained in:
Daniel Tartavel 2025-03-24 00:52:46 +08:00
parent a235d2f745
commit bdcccf378d
6 changed files with 115 additions and 79 deletions

View File

@ -2,7 +2,7 @@
Name: rsyncui Name: rsyncui
Summary: Client for rsync server Summary: Client for rsync server
Version: 2.13.1 Version: 2.13.2
Release: %mkrel 1 Release: %mkrel 1
License: GPLv3 License: GPLv3
Group: Networking/Remote access Group: Networking/Remote access

View File

@ -64,7 +64,7 @@ void MainWindow::download()
param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit]; param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit];
} }
ipversion = validateServer(server); ipversion = validateServer(&server);
if (downloading.ipversion == 4 || downloading.ipversion == 6) if (downloading.ipversion == 4 || downloading.ipversion == 6)
{ {

View File

@ -320,7 +320,7 @@ void MainWindow::populateTree()
info(DEBUGMACRO, "Validating server"); info(DEBUGMACRO, "Validating server");
// validating server's address // validating server's address
this->connexion.ipversion = validateServer(this->connexion.server); this->connexion.ipversion = validateServer(&this->connexion.server);
if (this->connexion.ipversion != 0) if (this->connexion.ipversion != 0)
{ {
// server is validated, scanning directory // server is validated, scanning directory
@ -347,18 +347,22 @@ void MainWindow::populateList(QString server, uint port)
info(DEBUGMACRO, "populateList() => Populating list of services"); info(DEBUGMACRO, "populateList() => Populating list of services");
info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server); info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server);
if (server.isEmpty()) if (server.isEmpty())
{ {
ui->listWidget->clear(); ui->listWidget->clear();
ui->treeWidget->clear(); ui->treeWidget->clear();
return; return;
} }
if ((server != this->connexion.server))
if (server != this->connexion.server)
{ {
// Determine version of Ip Protocol // Determine version of Ip Protocol
info(DEBUGMACRO, "Server changed"); info(DEBUGMACRO, "Server changed");
this->connexion.ipversion = validateServer(&server);
this->connexion.server = server; this->connexion.server = server;
if (port != false) if (port != false)
{ {
this->connexion.port = port; this->connexion.port = port;
@ -400,7 +404,7 @@ void MainWindow::populateList(QString server, uint port)
{ {
if (this->connexion.ipversion == 0) if (this->connexion.ipversion == 0)
{ {
this->connexion.ipversion = validateServer(server); this->connexion.ipversion = validateServer(&server);
info(DEBUGMACRO, "IP version : " + QString::number(this->connexion.ipversion)); info(DEBUGMACRO, "IP version : " + QString::number(this->connexion.ipversion));
} }
@ -779,27 +783,35 @@ uint MainWindow::validateServer(QString *server)
QHostAddress serverAddress; QHostAddress serverAddress;
info(DEBUGMACRO, "ValidateServer() => Validating server address"); info(DEBUGMACRO, "ValidateServer() => Validating server address");
ipversion = whatIpVersion(*server);
if (ipversion == 0) // not an Ip address, perhaps a server name //if (ipversion == 0) // not an Ip address, perhaps a server name
{ //{
serverAddress = searchHosts(*server); serverAddress = searchHosts(*server);
if (!serverAddress.isNull()) if (!serverAddress.isNull())
{ {
server->clear(); server->clear();
server->append(serverAddress.toString()); server->append(serverAddress.toString());
} info(DEBUGMACRO, "Server address : " + *server);
}else
{
if (!serverAddress.setAddress(*server))
{
info(DEBUGMACRO, "Digging server name"); info(DEBUGMACRO, "Digging server name");
cmd = "dig"; cmd = "dig";
param << server->trimmed() ; param << server->trimmed() ;
if (ipversion == IPV4)
{
param << "A"; // IP V4 query param << "A"; // IP V4 query
param << server->trimmed() ; }else if (ipversion == IPV6)
{
param << "AAAA"; // IP V6 query param << "AAAA"; // IP V6 query
}else
{
error("Protocol is not IPV4 or IPV6 !!");
}
info(DEBUGMACRO, cmd + " " + param.join(" ")); info(DEBUGMACRO, cmd + " " + param.join(" "));
@ -833,12 +845,11 @@ uint MainWindow::validateServer(QString *server)
info(DEBUGMACRO, "line is:\n" + line); info(DEBUGMACRO, "line is:\n" + line);
responseList = line.split(QRegExp("\\s+")); responseList = line.split(QRegExp("\\s+"));
info(DEBUGMACRO, "ip Address is => " + responseList.at(4)); info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
if(responseList.at(3) == "A") if (serverAddress.setAddress(responseList.at(4)))
{ {
return 4; //error ("Address " + responseList.at(4) + " is bad");
}else if(responseList.at(3) == "AAAA") server->clear();
{ server->append(serverAddress.toString());
return 6;
} }
} }
} }
@ -847,8 +858,14 @@ uint MainWindow::validateServer(QString *server)
} }
myProcess->close(); myProcess->close();
} }
}
info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion)); info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion));
return ipversion; //ipversion = whatIpVersion(*server);
ipversion = serverAddress.protocol();
return (ipversion==IPV4?4:6);
} }
@ -857,12 +874,14 @@ void MainWindow::on_connectButton_clicked()
{ {
QString server; QString server;
uint port; uint port;
//uint ipversion;
info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked"); info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked");
port = ui->portEdit->text().toUInt(); port = ui->portEdit->text().toUInt();
if (port > 0 and port < 65535) if (port > 0 and port < 65535)
{ {
server = ui->khistorycombobox->currentText(); server = ui->khistorycombobox->currentText();
//ipversion = validateServer(&server);
populateList(server, port); populateList(server, port);
}else }else
{ {

View File

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

View File

@ -3,6 +3,9 @@
#define DEBUGMACRO QString(__FILE__) + "->" + QString(Q_FUNC_INFO) + ": " + QString::number(__LINE__) + " -" #define DEBUGMACRO QString(__FILE__) + "->" + QString(Q_FUNC_INFO) + ": " + QString::number(__LINE__) + " -"
#define IPV4 0
#define IPV6 1
#include <QHostAddress> #include <QHostAddress>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -3,6 +3,6 @@
#include <QString> #include <QString>
QString version = "2.13.1"; QString version = "2.13.2";
#endif // VERSION_H #endif // VERSION_H