aboutsummaryrefslogtreecommitdiff
path: root/src/transport/tls
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-22 14:05:10 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-22 17:11:58 -0800
commit3d075fad7496ec126c5087d1c36ab7a4af73ce16 (patch)
treec5b5d6fe44eaa2996310683b5080de87160b9b41 /src/transport/tls
parent5b1a3af7be4ae712868ae84b9a7d5a974d272b16 (diff)
downloadnng-3d075fad7496ec126c5087d1c36ab7a4af73ce16.tar.gz
nng-3d075fad7496ec126c5087d1c36ab7a4af73ce16.tar.bz2
nng-3d075fad7496ec126c5087d1c36ab7a4af73ce16.zip
fixes #219 transports should take URL structure instead of string address
This eliminates a bunch of redundant URL parsing, using the common URL logic we already have in place. While here I fixed a problem with the TLS and WSS test suites that was failing on older Ubuntu -- apparently older versions of mbedTLS were unhappy if selecting OPTIONAL verification without a validate certificate chain.
Diffstat (limited to 'src/transport/tls')
-rw-r--r--src/transport/tls/tls.c17
1 files changed, 1 insertions, 16 deletions
diff --git a/src/transport/tls/tls.c b/src/transport/tls/tls.c
index 753a1e75..6bc884e7 100644
--- a/src/transport/tls/tls.c
+++ b/src/transport/tls/tls.c
@@ -537,16 +537,13 @@ nni_tls_ep_fini(void *arg)
if (ep->cfg) {
nni_tls_config_fini(ep->cfg);
}
- if (ep->url) {
- nni_url_free(ep->url);
- }
nni_aio_fini(ep->aio);
nni_mtx_fini(&ep->mtx);
NNI_FREE_STRUCT(ep);
}
static int
-nni_tls_ep_init(void **epp, const char *addr, nni_sock *sock, int mode)
+nni_tls_ep_init(void **epp, nni_url *url, nni_sock *sock, int mode)
{
nni_tls_ep * ep;
int rv;
@@ -557,26 +554,17 @@ nni_tls_ep_init(void **epp, const char *addr, nni_sock *sock, int mode)
int passive;
nng_tls_mode tlsmode;
nng_tls_auth_mode authmode;
- nni_url * url;
-
- // Parse the URLs first.
- if ((rv = nni_url_parse(&url, addr)) != 0) {
- return (rv);
- }
// Check for invalid URL components.
if ((strlen(url->u_path) != 0) && (strcmp(url->u_path, "/") != 0)) {
- nni_url_free(url);
return (NNG_EADDRINVAL);
}
if ((url->u_fragment != NULL) || (url->u_userinfo != NULL) ||
(url->u_query != NULL)) {
- nni_url_free(url);
return (NNG_EADDRINVAL);
}
if ((rv = nni_aio_init(&aio, NULL, NULL)) != 0) {
- nni_url_free(url);
return (rv);
}
@@ -598,7 +586,6 @@ nni_tls_ep_init(void **epp, const char *addr, nni_sock *sock, int mode)
lsa.s_un.s_family = NNG_AF_UNSPEC;
aio->a_addr = &rsa;
if ((host == NULL) || (serv == NULL)) {
- nni_url_free(url);
nni_aio_fini(aio);
return (NNG_EADDRINVAL);
}
@@ -615,14 +602,12 @@ nni_tls_ep_init(void **epp, const char *addr, nni_sock *sock, int mode)
nni_plat_tcp_resolv(host, serv, NNG_AF_UNSPEC, passive, aio);
nni_aio_wait(aio);
if ((rv = nni_aio_result(aio)) != 0) {
- nni_url_free(url);
nni_aio_fini(aio);
return (rv);
}
nni_aio_fini(aio);
if ((ep = NNI_ALLOC_STRUCT(ep)) == NULL) {
- nni_url_free(url);
return (NNG_ENOMEM);
}
nni_mtx_init(&ep->mtx);