aboutsummaryrefslogtreecommitdiff
path: root/src/transport/ws
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-05-22 10:27:47 -0700
committerGarrett D'Amore <garrett@damore.org>2018-05-22 10:29:06 -0700
commit959eabe2675a3b8be9bc2b2459cc899a5a64b283 (patch)
tree373fba9ab3c7cf4c769efb1c42f896694bf16d25 /src/transport/ws
parent67f5ed6e5c0dd7bdd9002bbb519ab34f35fef8dd (diff)
downloadnng-959eabe2675a3b8be9bc2b2459cc899a5a64b283.tar.gz
nng-959eabe2675a3b8be9bc2b2459cc899a5a64b283.tar.bz2
nng-959eabe2675a3b8be9bc2b2459cc899a5a64b283.zip
fixes #474 websocket listen on ws://*:<x> fails
fixes #464 Support NN_WS_MSG_TYPE option (compat) fixes #415 websocket does not honor recv maxsize This fixes a significant (and security) issue in websocket, where the code does not honor a maximum receive size. We've exposed new API (internal) to set the limit on the frame size, and we've changed the default to *unlimited* for that internal API. (But the default for SP sockets, which are the only consumers at present, is still 1MB just like all other SP transports.)
Diffstat (limited to 'src/transport/ws')
-rw-r--r--src/transport/ws/websocket.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/transport/ws/websocket.c b/src/transport/ws/websocket.c
index 36deddac..97175d49 100644
--- a/src/transport/ws/websocket.c
+++ b/src/transport/ws/websocket.c
@@ -284,7 +284,9 @@ ws_ep_bind(void *arg)
ws_ep *ep = arg;
int rv;
+ nni_ws_listener_set_maxframe(ep->listener, ep->rcvmax);
nni_ws_listener_hook(ep->listener, ws_hook, ep);
+
if ((rv = nni_ws_listener_listen(ep->listener)) == 0) {
ep->started = true;
}
@@ -359,6 +361,7 @@ ws_ep_connect(void *arg, nni_aio *aio)
NNI_ASSERT(nni_list_empty(&ep->aios));
ep->started = true;
nni_list_append(&ep->aios, aio);
+ nni_ws_dialer_set_maxframe(ep->dialer, ep->rcvmax);
nni_ws_dialer_dial(ep->dialer, ep->connaio);
nni_mtx_unlock(&ep->mtx);
}
@@ -373,6 +376,11 @@ ws_ep_setopt_recvmaxsz(void *arg, const void *v, size_t sz, int typ)
rv = nni_copyin_size(&val, v, sz, 0, NNI_MAXSZ, typ);
if ((rv == 0) && (ep != NULL)) {
ep->rcvmax = val;
+ if (ep->mode == NNI_EP_MODE_DIAL) {
+ nni_ws_dialer_set_maxframe(ep->dialer, ep->rcvmax);
+ } else {
+ nni_ws_listener_set_maxframe(ep->listener, ep->rcvmax);
+ }
}
return (rv);
}