Move error logging of adding peers to the proper place

This commit is contained in:
Chocobo1
2019-09-03 13:58:35 +08:00
parent 80bf5978de
commit 2396ef5bd6
4 changed files with 40 additions and 13 deletions

View File

@@ -30,7 +30,9 @@
#include <QString>
BitTorrent::PeerAddress BitTorrent::PeerAddress::parse(const QString &address)
using namespace BitTorrent;
PeerAddress PeerAddress::parse(const QString &address)
{
QVector<QStringRef> ipPort;
@@ -55,3 +57,14 @@ BitTorrent::PeerAddress BitTorrent::PeerAddress::parse(const QString &address)
return {ip, port};
}
QString PeerAddress::toString() const
{
if (ip.isNull())
return {};
const QString ipStr = (ip.protocol() == QAbstractSocket::IPv6Protocol)
? ('[' + ip.toString() + ']')
: ip.toString();
return (ipStr + ':' + QString::number(port));
}