aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/tls/tls_stream.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-10-26 10:54:58 -0700
committerGarrett D'Amore <garrett@damore.org>2025-10-27 07:13:40 -0700
commitbe13c2e8845423cec17af429fc4e16a5d9749e47 (patch)
tree82614e403a41aac6581a9a223ef9eba5be557222 /src/supplemental/tls/tls_stream.c
parent11c53f3d7f747d14fd69ce98c63d629bc821ef68 (diff)
downloadnng-be13c2e8845423cec17af429fc4e16a5d9749e47.tar.gz
nng-be13c2e8845423cec17af429fc4e16a5d9749e47.tar.bz2
nng-be13c2e8845423cec17af429fc4e16a5d9749e47.zip
Replace nng_pipe_get_addr, nng_stream_get_addr, and the NNG_OPT_REMADDR option.
More direct access methods are provided instead. This results in much lower friction when using, and is a step on the path to removing NNG_OPT_LOCADDR as well. We need to figure a solution for NNG_OPT_LOCADDR for dialers; for listeners there is little use in it either, and it will be removed. (Dialers will probably get a new NNG_OPT_BIND_IP option.)
Diffstat (limited to 'src/supplemental/tls/tls_stream.c')
-rw-r--r--src/supplemental/tls/tls_stream.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/supplemental/tls/tls_stream.c b/src/supplemental/tls/tls_stream.c
index d0a1fabd..b523e583 100644
--- a/src/supplemental/tls/tls_stream.c
+++ b/src/supplemental/tls/tls_stream.c
@@ -111,10 +111,10 @@ tls_stream_recv(void *arg, nng_aio *aio)
static void
tls_stream_conn_cb(void *arg)
{
- tls_stream *ts = arg;
- nng_stream *bio;
- int rv;
- nng_sockaddr sa;
+ tls_stream *ts = arg;
+ nng_stream *bio;
+ int rv;
+ const nng_sockaddr *sa;
if ((rv = nni_aio_result(&ts->conn_aio)) != 0) {
nni_aio_finish_error(ts->user_aio, rv);
@@ -123,13 +123,9 @@ tls_stream_conn_cb(void *arg)
}
bio = nni_aio_get_output(&ts->conn_aio, 0);
- if ((rv = nng_stream_get_addr(bio, NNG_OPT_REMADDR, &sa)) != 0) {
- nni_aio_finish_error(ts->user_aio, rv);
- nni_tls_stream_free(ts);
- return;
- };
+ sa = nng_stream_peer_addr(bio);
- if ((rv = nni_tls_start(&ts->conn, &tls_stream_bio, bio, &sa)) != 0) {
+ if ((rv = nni_tls_start(&ts->conn, &tls_stream_bio, bio, sa)) != 0) {
// NB: if this fails, it *will* have set the bio either way.
// So nni_tls_stream_free will also free the bio.
nni_aio_finish_error(ts->user_aio, rv);