Skip to content

Commit

Permalink
Fixed|Address: Issues with non-looked-up addresses
Browse files Browse the repository at this point in the history
Use the provided text representation as-is before looking up the
address.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent cfee68f commit 7361fc0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions doomsday/libs/core/include/de/net/address.h
Expand Up @@ -54,14 +54,14 @@ class DE_PUBLIC Address : public LogEntry::Arg::Base

operator const iAddress *() const;

Address &operator=(Address const &other);
Address &operator=(const Address &other);

/**
* Returns the host name that was passed to lookup.
*/
String hostName() const;

bool operator<(Address const &other) const;
bool operator<(const Address &other) const;

/**
* Checks two addresses for equality.
Expand All @@ -70,7 +70,7 @@ class DE_PUBLIC Address : public LogEntry::Arg::Base
*
* @return @c true if the addresses are equal.
*/
bool operator==(Address const &other) const;
bool operator==(const Address &other) const;

bool isNull() const;

Expand Down
22 changes: 17 additions & 5 deletions doomsday/libs/core/src/net/address.cpp
Expand Up @@ -81,22 +81,25 @@ Address Address::take(iAddress *addr)

Address::Address(const Address &other) : d(new Impl)
{
d->_addr.reset(other.d->_addr); // use the same object
d->port = other.d->port;
d->_addr.reset(other.d->_addr); // reference the same object
d->port = other.d->port;
d->pendingLookup = other.d->pendingLookup;
d->textRepr = other.d->textRepr;
d->special = other.d->special;
}

Address::operator const iAddress *() const
{
return d->get();
}

Address &Address::operator=(Address const &other)
Address &Address::operator=(const Address &other)
{
d->_addr.reset(other.d->_addr); // use the same object
d->_addr.reset(other.d->_addr); // reference the same object
d->pendingLookup = other.d->pendingLookup;
d->port = other.d->port;
d->textRepr = other.d->textRepr;
d->special = other.d->special;
d->pendingLookup = other.d->pendingLookup;
return *this;
}

Expand Down Expand Up @@ -160,6 +163,15 @@ duint16 Address::port() const

String Address::asText() const
{
if (d->pendingLookup)
{
String str = d->pendingLookup;
if (d->port)
{
str += Stringf(":%u", d->port);
}
return str;
}
if (isNull())
{
return {};
Expand Down

0 comments on commit 7361fc0

Please sign in to comment.