version 2.13.2
This commit is contained in:
parent
a235d2f745
commit
bdcccf378d
@ -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
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
149
mainwindow.cpp
149
mainwindow.cpp
@ -101,15 +101,15 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
// if last server exists in settings
|
// if last server exists in settings
|
||||||
if (this->settings.contains("connexion/lastServer"))
|
if (this->settings.contains("connexion/lastServer"))
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "Setting previous server");
|
info(DEBUGMACRO, "Setting previous server");
|
||||||
// set window to previous server/port configuration
|
// set window to previous server/port configuration
|
||||||
ui->portEdit->setText(this->settings.value("connexion/lastPort").toString());
|
ui->portEdit->setText(this->settings.value("connexion/lastPort").toString());
|
||||||
ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString());
|
ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString());
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "No previous server, so setting only default port");
|
info(DEBUGMACRO, "No previous server, so setting only default port");
|
||||||
ui->portEdit->setText(QString::number(this->connexion.port));
|
ui->portEdit->setText(QString::number(this->connexion.port));
|
||||||
ui->khistorycombobox->clear();
|
ui->khistorycombobox->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectors
|
// connectors
|
||||||
@ -146,11 +146,11 @@ void MainWindow::init()
|
|||||||
info(DEBUGMACRO, "reply text is : " + reply->text());
|
info(DEBUGMACRO, "reply text is : " + reply->text());
|
||||||
if(reply == yes)
|
if(reply == yes)
|
||||||
{
|
{
|
||||||
loadDownloadList();
|
loadDownloadList();
|
||||||
}else if (reply == deleteButton)
|
}else if (reply == deleteButton)
|
||||||
{
|
{
|
||||||
// delete saved download list
|
// delete saved download list
|
||||||
deleteDownloadList();
|
deleteDownloadList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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,76 +783,89 @@ 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);
|
||||||
|
if (!serverAddress.isNull())
|
||||||
{
|
{
|
||||||
|
server->clear();
|
||||||
serverAddress = searchHosts(*server);
|
server->append(serverAddress.toString());
|
||||||
if (!serverAddress.isNull())
|
info(DEBUGMACRO, "Server address : " + *server);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
if (!serverAddress.setAddress(*server))
|
||||||
{
|
{
|
||||||
server->clear();
|
|
||||||
server->append(serverAddress.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
info(DEBUGMACRO, "Digging server name");
|
||||||
|
|
||||||
|
cmd = "dig";
|
||||||
info(DEBUGMACRO, "Digging server name");
|
param << server->trimmed() ;
|
||||||
|
if (ipversion == IPV4)
|
||||||
cmd = "dig";
|
|
||||||
param << server->trimmed() ;
|
|
||||||
param << "A"; // IP V4 query
|
|
||||||
param << server->trimmed() ;
|
|
||||||
param << "AAAA"; // IP V6 query
|
|
||||||
|
|
||||||
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
|
||||||
|
|
||||||
myProcess = new QProcess(this);
|
|
||||||
myProcess->start(cmd, param);
|
|
||||||
|
|
||||||
// making a dig on the server's address
|
|
||||||
while(myProcess->waitForReadyRead())
|
|
||||||
{
|
|
||||||
while (1) //!bflag)
|
|
||||||
{
|
{
|
||||||
line = QString::fromUtf8(myProcess->readAllStandardOutput());
|
param << "A"; // IP V4 query
|
||||||
info(DEBUGMACRO, line);
|
}else if (ipversion == IPV6)
|
||||||
// line empty then buffer is empty so returning to wait new datas
|
{
|
||||||
if (line.isEmpty())
|
param << "AAAA"; // IP V6 query
|
||||||
{
|
}else
|
||||||
break;
|
{
|
||||||
}else
|
error("Protocol is not IPV4 or IPV6 !!");
|
||||||
{
|
}
|
||||||
answerFound = line.indexOf(";; ANSWER SECTION:") + 19;
|
|
||||||
info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound));
|
|
||||||
|
|
||||||
if (answerFound != -1)
|
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
||||||
|
|
||||||
|
myProcess = new QProcess(this);
|
||||||
|
myProcess->start(cmd, param);
|
||||||
|
|
||||||
|
// making a dig on the server's address
|
||||||
|
while(myProcess->waitForReadyRead())
|
||||||
|
{
|
||||||
|
while (1) //!bflag)
|
||||||
|
{
|
||||||
|
line = QString::fromUtf8(myProcess->readAllStandardOutput());
|
||||||
|
info(DEBUGMACRO, line);
|
||||||
|
// line empty then buffer is empty so returning to wait new datas
|
||||||
|
if (line.isEmpty())
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "Serching IP address");
|
break;
|
||||||
queryPos = line.indexOf(";; Query");
|
}else
|
||||||
info(DEBUGMACRO, "Position of Query line is : " + QString::number(queryPos));
|
{
|
||||||
if (answerFound < queryPos)
|
answerFound = line.indexOf(";; ANSWER SECTION:") + 19;
|
||||||
|
info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound));
|
||||||
|
|
||||||
|
if (answerFound != -1)
|
||||||
{
|
{
|
||||||
line = line.mid(answerFound, queryPos - answerFound);
|
info(DEBUGMACRO, "Serching IP address");
|
||||||
info(DEBUGMACRO, "line is:\n" + line);
|
queryPos = line.indexOf(";; Query");
|
||||||
responseList = line.split(QRegExp("\\s+"));
|
info(DEBUGMACRO, "Position of Query line is : " + QString::number(queryPos));
|
||||||
info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
|
if (answerFound < queryPos)
|
||||||
if(responseList.at(3) == "A")
|
|
||||||
{
|
{
|
||||||
return 4;
|
line = line.mid(answerFound, queryPos - answerFound);
|
||||||
}else if(responseList.at(3) == "AAAA")
|
info(DEBUGMACRO, "line is:\n" + line);
|
||||||
{
|
responseList = line.split(QRegExp("\\s+"));
|
||||||
return 6;
|
info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
|
||||||
|
if (serverAddress.setAddress(responseList.at(4)))
|
||||||
|
{
|
||||||
|
//error ("Address " + responseList.at(4) + " is bad");
|
||||||
|
server->clear();
|
||||||
|
server->append(serverAddress.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
||||||
{
|
{
|
||||||
|
36
tools.cpp
36
tools.cpp
@ -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)
|
||||||
{
|
//{
|
||||||
serverAddress.setAddress(hosts.first());
|
if (!serverAddress.setAddress(hosts.first()))
|
||||||
}
|
{
|
||||||
|
error("Error setting address " + hosts.first());
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return serverAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warning(QString message)
|
void warning(QString message)
|
||||||
|
3
tools.h
3
tools.h
@ -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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user