Unverified Commit bba84f01 authored by Aaron Wyatt's avatar Aaron Wyatt Committed by GitHub
Browse files

Add files via upload

Remove unnecessary reverse DNS lookups when an IP address is supplied.
parent 1450c17e
......@@ -601,10 +601,12 @@ int JackTrip::clientPingToServerStart() throw(std::invalid_argument)
// --------------------
QTcpSocket tcpClient;
QHostAddress serverHostAddress;
QHostInfo info = QHostInfo::fromName(mPeerAddress);
if (!info.addresses().isEmpty()) {
// use the first IP address
serverHostAddress = info.addresses().first();
if (!serverHostAddress.setAddress(mPeerAddress)) {
QHostInfo info = QHostInfo::fromName(mPeerAddress);
if (!info.addresses().isEmpty()) {
// use the first IP address
serverHostAddress = info.addresses().first();
}
}
// Connect Socket to Server and wait for response
......
......@@ -103,19 +103,20 @@ UdpDataProtocol::~UdpDataProtocol()
void UdpDataProtocol::setPeerAddress(const char* peerHostOrIP) throw(std::invalid_argument)
{
// Get DNS Address
QHostInfo info = QHostInfo::fromName(peerHostOrIP);
if (!info.addresses().isEmpty()) {
// use the first IP address
mPeerAddress = info.addresses().first();
if (mPeerAddress.protocol() == QAbstractSocket::IPv6Protocol) {
mIPv6 = true;
if (!mPeerAddress.setAddress(peerHostOrIP)) {
QHostInfo info = QHostInfo::fromName(peerHostOrIP);
if (!info.addresses().isEmpty()) {
// use the first IP address
mPeerAddress = info.addresses().first();
}
//cout << "UdpDataProtocol::setPeerAddress IP Address Number: "
// << mPeerAddress.toString().toStdString() << endl;
}
// check if the ip address is valid
if ( mPeerAddress.isNull() ) {
if ( mPeerAddress.protocol() == QAbstractSocket::IPv6Protocol ) {
mIPv6 = true;
} else if ( mPeerAddress.protocol() != QAbstractSocket::IPv4Protocol ) {
QString error_message = "Incorrect presentation format address\n '";
error_message.append(peerHostOrIP);
error_message.append("' is not a valid IP address or Host Name");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment