1.0.2 • Published 10 years ago
ipp-spy v1.0.2
ipp-spy
Listen for IPP requests on a given port and proxy requests to a real IPP printer. Allows for spying on the traffic between the client and the server.
Installation
npm install ipp-spy --saveUsage Example
Start an IPP printer spy on port 3000 and proxy all requests to
example.com:
var spy = require('ipp-spy')
var opts = {
port: 3000
forwardHost: 'example.com', // defaults to localhost
forwardPort: 631 // default to 631
}
spy(opts, function (operation, document) {
console.log('New IPP operation:', operation)
var bytes = 0
document.on('data', function (chunk) {
bytes += chunk.length
})
document.on('end', function () {
console.log('Attached document size: %d bytes', bytes)
})
})API
The module exposes a generator function which creates a new spy proxy. An EventEmitter is returned:
var server = spy(options[, onOperation])Options:
port- the port that the spy should listen onforwardHost- the host to forward requests to (defaults tolocalhost)forwardPort- the port to forward requests to (defaults to631)
The optional onOperation callback argument will be attached to the
operation event emitted by the returned EventEmitter.
The returned EventEmitter can emmit the following events:
Event: connection
function (client, server) {}Emitted every time a new TCP connection is made to the spy proxy.
client- a TCP socket streaming the data coming from the clientserver- a TCP socket streaming the data returned from the server
Event: operation
function (operation, document) {}Emitted every time an IPP request is sent to the spy.
The callback is called with two arguments:
operation- the IPP opperation metadata. See ipp-encoder for detailsdocument- a readable stream containing the body of the IPP request (i.e. the document being printed)
License
MIT