MINOR: stream/cli: use conn_get_{src,dst} in "show sess" and "show peers" output
The stream outputs requires to retrieve connections sources and
destinations. The previous call involving conn_get_{to,from}_addr()
was missing a status check which has now been integrated with the
new call since these places already handle connection errors there.
The same code parts were reused for "show peers" and were modified
similarly.
diff --git a/src/peers.c b/src/peers.c
index 69fed6d..bdaf498 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -3128,7 +3128,7 @@
if (conn)
chunk_appendf(&trash, "\n xprt=%s", conn_get_xprt_name(conn));
- switch (conn ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) {
+ switch (conn && conn_get_src(conn) ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " src=%s:%d", pn, get_host_port(&conn->addr.from));
@@ -3138,10 +3138,7 @@
break;
}
- if (conn)
- conn_get_to_addr(conn);
-
- switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
+ switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d", pn, get_host_port(&conn->addr.to));
diff --git a/src/stream.c b/src/stream.c
index e240551..fb5555c 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -3083,10 +3083,7 @@
strm_li(strm) ? strm_li(strm)->name ? strm_li(strm)->name : "?" : "?",
strm_li(strm) ? strm_li(strm)->luid : 0);
- if (conn)
- conn_get_to_addr(conn);
-
- switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
+ switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n",
@@ -3112,10 +3109,7 @@
cs = objt_cs(strm->si[1].end);
conn = cs_conn(cs);
- if (conn)
- conn_get_from_addr(conn);
-
- switch (conn ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) {
+ switch (conn && conn_get_src(conn) ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n",
@@ -3138,10 +3132,7 @@
else
chunk_appendf(&trash, " server=<NONE> (id=-1)");
- if (conn)
- conn_get_to_addr(conn);
-
- switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
+ switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n",