Skip to content

Commit

Permalink
feat: do not process 'null' as a WebSocket event listener (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
rentallect authored Oct 8, 2024
1 parent 1f732e8 commit 04c287c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/channel/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,13 +1153,14 @@ class ZitiChannel {
if (len > 2000) {
len = 2000;
}
this._zitiContext.logger.trace("recv <- unencrypted_data (first 2000): %s", m1.substring(0, len));
this._zitiContext.logger.trace("recv <- unencrypted_data (first 2000): ", m1.substring(0, len));

//
// let dbgStr = m1.substring(0, len);
// this._zitiContext.logger.trace("recv <- data (first 2000): %s", dbgStr);

} catch (e) {
} catch (e) {
// console.log('sodium.to_string error: ', e)
}

bodyView = unencrypted_data.message;
Expand Down
12 changes: 8 additions & 4 deletions src/context/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ class ZitiContext extends EventEmitter {
let config = result(find(this._services, function(obj) {
return obj.name === name;
}), 'config');
this.logger.trace(`getServiceConfigByName() service[${name}] has config[${config}]`);
this.logger.trace(`getServiceConfigByName() service[${name}] has config: `, config);

if (isUndefined(config)) {
// Let any listeners know there are no configs associated with the given service,
Expand Down Expand Up @@ -2337,9 +2337,13 @@ class ZitiContext extends EventEmitter {
counter: request.counter
};

let body = res.pipe(new PassThrough( response_options ));

let response = new HttpResponse(body, response_options);
let response;
if (isEqual(res.statusCode, 204)) {
response = new HttpResponse(null, response_options);
} else {
let body = res.pipe(new PassThrough( response_options ));
response = new HttpResponse(body, response_options);
}

for (const hdr in response_options.headers) {
if (response_options.headers.hasOwnProperty(hdr)) {
Expand Down
1 change: 1 addition & 0 deletions src/http/ziti-websocket-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ readyStates.forEach((readyState, i) => {
* @public
*/
set(listener) {
if (isNull(listener) || isUndefined(listener)) { return; }
const listeners = this.listeners(method);
for (let i = 0; i < listeners.length; i++) {
//
Expand Down

0 comments on commit 04c287c

Please sign in to comment.