Skip to content

Commit

Permalink
Cleanup|libcore|libshell: Show local addresses always as "localhost"
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 8, 2016
1 parent e9c1f0f commit 9d3d5ad
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doomsday/sdk/libcore/src/net/address.cpp
Expand Up @@ -124,7 +124,7 @@ bool Address::matches(Address const &other, duint32 mask)

String Address::asText() const
{
String result = (d->host == QHostAddress::LocalHost? "localhost" : d->host.toString());
String result = (isLocal()? String("localhost") : d->host.toString());
if (d->port)
{
result += ":" + QString::number(d->port);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libcore/src/net/beacon.cpp
Expand Up @@ -98,7 +98,7 @@ void Beacon::setMessage(IByteArray const &advertisedMessage)

d->message += Block(advertisedMessage).compressed();

qDebug() << "Beacon message:" << advertisedMessage.size() << d->message.size();
//qDebug() << "Beacon message:" << advertisedMessage.size() << d->message.size();
}

void Beacon::stop()
Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libcore/src/net/listensocket.cpp
Expand Up @@ -75,7 +75,7 @@ Socket *ListenSocket::accept()
}

QTcpSocket *s = d->incoming.takeFirst();
LOG_NET_NOTE("Accepted new connection from %s") << s->peerAddress().toString();
LOG_NET_NOTE("Accepted new connection from %s") << Address(s->peerAddress()).asText();

// We can use this constructor because we are Socket's friend.
return new Socket(s);
Expand Down
6 changes: 5 additions & 1 deletion doomsday/sdk/libshell/src/serverfinder.cpp
Expand Up @@ -136,7 +136,9 @@ ServerInfo ServerFinder::messageFromServer(Address const &address) const
throw NotFoundError("ServerFinder::messageFromServer",
"No message from server " + address.asText());
}
return ServerInfo(*d->servers[address].message);
ServerInfo info(*d->servers[address].message);
info.setAddress(address);
return info;
}

void ServerFinder::found(Address host, Block block)
Expand All @@ -163,6 +165,8 @@ void ServerFinder::found(Address host, Block block)
}
Reader(block).withHeader() >> *found.message;

//qDebug() << "Server found:\n" << found.message->asText().toLatin1().constData();

emit updated();
}
catch (Error const &)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/tools/shell/src/linkwindow.cpp
Expand Up @@ -131,7 +131,8 @@ DENG2_PIMPL(LinkWindow)
if (self.isConnected() && !link->address().isNull())
{
txt = tr("<b>%1</b>:%2")
.arg(link->address().host().toString())
.arg(link->address().isLocal()? "localhost"
: link->address().host().toString())
.arg(link->address().port());
}
else if (self.isConnected() && link->address().isNull())
Expand Down

0 comments on commit 9d3d5ad

Please sign in to comment.