Skip to content

Commit

Permalink
SocketEndpoint::getEndpointText -> SocketEndpoint::getEndpointIpText
Browse files Browse the repository at this point in the history
  • Loading branch information
jakesmith committed Sep 22, 2023
1 parent 0ace2a8 commit c61c9b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
36 changes: 17 additions & 19 deletions system/jlib/jsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3852,6 +3852,22 @@ bool SocketEndpoint::set(const char *name,unsigned short _port)
return false;
}

StringBuffer &SocketEndpoint::getEndpointIpText(StringBuffer &str) const
{
getIpText(str);
if (port)
str.append(':').append((unsigned)port); // TBD IPv6 put [] on
return str;
}

StringBuffer &SocketEndpoint::getEndpointHostText(StringBuffer &str) const
{
getHostText(str);
if (port)
str.append(':').append((unsigned)port); // TBD IPv6 put [] on
return str;
}

void SocketEndpoint::getEndpointHostText(char * str, size32_t len) const
{
if (len==0)
Expand All @@ -3867,24 +3883,6 @@ void SocketEndpoint::getEndpointHostText(char * str, size32_t len) const
memcpy(str,_str.str(),l);
}

// NB: this and getHostText returns stored hostname if available
StringBuffer &SocketEndpoint::getEndpointHostText(StringBuffer &str) const
{
getHostText(str);
if (port)
str.append(':').append((unsigned)port); // TBD IPv6 put [] on
return str;
}

// NB: this and getEndpointText returns a resolved IP
StringBuffer &SocketEndpoint::getEndpointText(StringBuffer &str) const
{
getIpText(str);
if (port)
str.append(':').append((unsigned)port); // TBD IPv6 put [] on
return str;
}

unsigned SocketEndpoint::hash(unsigned prev) const
{
return hashc((const byte *)&port,sizeof(port),iphash(prev));
Expand All @@ -3894,7 +3892,7 @@ unsigned SocketEndpoint::hash(unsigned prev) const
StringBuffer &conditionalGetHostUrlStr(StringBuffer &str, const SocketEndpoint &ep)
{
if (isContainerized())
return ep.getEndpointText(str);
return ep.getEndpointIpText(str);
else
return ep.getEndpointHostText(str);
}
Expand Down
2 changes: 1 addition & 1 deletion system/jlib/jsocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class jlib_decl SocketEndpoint : extends IpAddress
inline void setLocalHost(unsigned short _port) { port = _port; GetHostIp(*this); } // NB *not* localhost(127.0.0.1)
inline void set(unsigned short _port, const IpAddress & _ip) { ipset(_ip); port = _port; };
inline bool equals(const SocketEndpoint &ep) const { return ((port==ep.port)&&ipequals(ep)); }
StringBuffer &getEndpointText(StringBuffer &str) const;
StringBuffer &getEndpointIpText(StringBuffer &str) const;
void getEndpointHostText(char * str, size32_t len) const; // in form ip4:port or [ip6]:port
StringBuffer &getEndpointHostText(StringBuffer &str) const; // in form ip4:port or [ip6]:port

Expand Down

0 comments on commit c61c9b1

Please sign in to comment.