aboutsummaryrefslogtreecommitdiff
path: root/src/core/transport.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-05 14:44:10 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-05 15:17:27 -0800
commit1b2f22fd68a2e50cabdfe2e036096cc9e7a05a1f (patch)
tree95fc90338cbe38a46e561511604cf8ed079934fd /src/core/transport.c
parent224dae56a379aa309fca261d61e7e356b14a536f (diff)
downloadnng-1b2f22fd68a2e50cabdfe2e036096cc9e7a05a1f.tar.gz
nng-1b2f22fd68a2e50cabdfe2e036096cc9e7a05a1f.tar.bz2
nng-1b2f22fd68a2e50cabdfe2e036096cc9e7a05a1f.zip
Convert existing websocket and http code to use new URL framework.
This also fixes a use-after-free bug in the HTTP framework, where the handler could be deleted why callbacks were still using it. (We now reference count the handlers.)
Diffstat (limited to 'src/core/transport.c')
-rw-r--r--src/core/transport.c70
1 files changed, 2 insertions, 68 deletions
diff --git a/src/core/transport.c b/src/core/transport.c
index 9c129a72..0891ec8c 100644
--- a/src/core/transport.c
+++ b/src/core/transport.c
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -106,72 +106,6 @@ nni_tran_find(const char *addr)
return (NULL);
}
-// nni_tran_parse_host_port is a convenience routine to parse the host portion
-// of a URL (which includes a DNS name or IP address and an optional service
-// name or port, separated by a colon) into its host and port name parts. It
-// understands IPv6 address literals when surrounded by brackets ([]).
-// If either component is empty, then NULL is passed back for the value,
-// otherwise a string suitable for freeing with nni_strfree is supplied.
-int
-nni_tran_parse_host_port(const char *pair, char **hostp, char **portp)
-{
- const char *hstart;
- const char *pstart;
- char * host;
- char * port;
- size_t hlen, plen;
-
- if (pair[0] == '[') {
- hstart = pair + 1;
- hlen = 0;
- while (hstart[hlen] != ']') {
- if (hstart[hlen] == '\0') {
- return (NNG_EADDRINVAL);
- }
- hlen++;
- }
- pstart = hstart + hlen + 1; // skip over the trailing ']'
- } else {
- // Normal thing.
- hstart = pair;
- hlen = 0;
- while ((hstart[hlen] != ':') && (hstart[hlen] != '\0')) {
- hlen++;
- }
- pstart = hstart + hlen;
- }
- if (pstart[0] == ':') {
- pstart++;
- }
- plen = strlen(pstart);
-
- host = NULL;
- if (hostp) {
- if ((hlen > 1) || ((hlen == 1) && (*hstart != '*'))) {
- if ((host = nni_alloc(hlen + 1)) == NULL) {
- return (NNG_ENOMEM);
- }
- memcpy(host, hstart, hlen);
- host[hlen] = '\0';
- }
- }
-
- port = NULL;
- if ((plen != 0) && (portp)) {
- if ((port = nni_strdup(pstart)) == NULL) {
- nni_strfree(host);
- return (NNG_ENOMEM);
- }
- }
- if (hostp) {
- *hostp = host;
- }
- if (portp) {
- *portp = port;
- }
- return (0);
-}
-
int
nni_tran_chkopt(const char *name, const void *v, size_t sz)
{