Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodetunes

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodetunes - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

105

lib/rtsp.js

@@ -1,4 +0,5 @@

"use strict";
"use strict";
var net = require('net');
var Parser = require('httplike');
var tools = require('./rtspHelper');

@@ -23,101 +24,11 @@ var RtpServer = require('./rtp');

// return true if need to process content, false if done
var parseHeader = function(socket, msg) {
var response = new tools.MessageBuilder(socket);
// debug: dump message
//console.log('INSPECTING HEADER @ ' + socket.id.getTime());
//console.log('`--: ' + msg.replace(/\r\n/g, '\r\n`--: '));
//console.log('END HEADER\n\n');
// parse out the direction and header
var lines = msg.split('\r\n');
var methodline = lines[0].split(' ');
var method = methodline[0].toUpperCase();
// process headers
var headers = {};
for (var i = 1; i < lines.length; i++) {
var header = [ lines[i].substr(0, lines[i].indexOf(':')), lines[i].substr(lines[i].indexOf(':')+1) ];
if (header.length != 2) {
response.sendError(400);
return { "success" : false };
}
headers[header[0]] = header[1].replace(/^\s+|\s+$/gm, '');
}
if (!headers.hasOwnProperty('CSeq')) {
response.sendError(400);
};
// if there's a content-length, likely some sdp data to pull
if (headers.hasOwnProperty('Content-Length')) {
return { "success" : true, "method" : method, "response" : response, "headers" : headers, hasContent: true, contentLength: headers['Content-Length'] };
}
return { "success" : true, "method" : method, "response" : response, "headers" : headers, hasContent: false, contentLength: 0 };
};
var handler = function(socket) {
var buffer = '';
var binBuffer = null; // used only for binary content (e.g. dmap)
var hasContent = false;
var remaining = -1;
var terminator = '\r\n\r\n';
var headerData = null;
socket.id = new Date();
//console.log('OPENED CONNECTION @ ' + socket.id.getTime());
socket.on('data', function(c) {
self.external.emit('clientConnected');
// buffer and find messages
buffer += c;
if (remaining >= 0) {
remaining -= c.length;
Buffer.concat([ binBuffer, c ]);
//console.log('WAITING ON ' + remaining + ' BYTES OF CONTENT REMAINING (ONGOING)');
}
// check for termination, so we can pass on a header
if (buffer.indexOf(terminator) >= 0) {
var msgs = buffer.split(terminator);
// check the current headers; may or may not specify a payload (via Content-Length header)
headerData = parseHeader(socket, msgs[0]);
if (!headerData.hasContent) {
//console.log('CALLING ' + headerData.method + ' WITHOUT CONTENT');
methodMapping[headerData.method](headerData.response, headerData.headers);
//console.log('END CALL\n\n');
buffer = msgs[msgs.length - 1];
} else {
// we need to wait for the content to come through
//console.log('WAITING ON ' + headerData.contentLength + ' BYTES OF CONTENT');
remaining = headerData.contentLength;
hasContent = true;
// check the buffer to make sure stuff isn't overlooked
binBuffer = c.slice(buffer.indexOf(terminator) + 4);
buffer = msgs[msgs.length - 1] + '\r\n'; // compensate?
remaining -= buffer.length;
//console.log('WAITING ON ' + remaining + ' BYTES OF CONTENT REMAINING (INITIAL)');
//console.log('`--: ' + buffer.replace(/\r\n/g, '\r\n`--: '));
}
}
if (remaining <= 0 && hasContent && headerData) {
//console.log('CALLING ' + headerData.method + ' WITH FOLLOWING CONTENT');
//console.log('`--: ' + buffer.replace(/\r\n/g, '\r\n`--: '));
methodMapping[headerData.method](headerData.response, headerData.headers, binBuffer);
//console.log('END CALL\n\n');
binBuffer = null;
buffer = '';
hasContent = false;
remaining = -1;
}
var parser = new Parser(socket);
parser.on('message', function(m) {
var response = new tools.MessageBuilder(socket);
methodMapping[m.method](response, m.headers, m.content);
});

@@ -127,5 +38,5 @@

this.handler = handler;
self.handler = handler;
};
module.exports = server;

5

package.json
{
"name": "nodetunes",
"version": "0.0.3",
"version": "0.0.4",
"author": "Stephen Wan <stephen@stephenwan.net>",

@@ -25,3 +25,4 @@ "description": "AirTunes v2 Music Server",

"portastic" : "*",
"randomstring" : "*"
"randomstring" : "*",
"httplike" : "0.0.1"
},

@@ -28,0 +29,0 @@ "devDependencies" : {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc