node-sftp-server
Advanced tools
Comparing version 0.1.1 to 0.1.2
"use strict"; | ||
var ContextWrapper, DirectoryEmitter, EventEmitter, Readable, Responder, SFTP, SFTPFileStream, SFTPServer, SFTPSession, Statter, Transform, Writable, constants, fs, ssh2, ssh2_stream, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty, | ||
slice = [].slice; | ||
ssh2 = require('ssh2'); | ||
var ssh2 = require('ssh2'); | ||
var ssh2_stream = require('ssh2-streams'); | ||
var SFTP = ssh2_stream.SFTPStream; | ||
ssh2_stream = require('ssh2-streams'); | ||
var Readable = require('stream').Readable; | ||
var Writable = require('stream').Writable; | ||
var Transform = require('stream').Transform; | ||
SFTP = ssh2_stream.SFTPStream; | ||
var EventEmitter = require("events").EventEmitter; | ||
var fs = require('fs'); | ||
Readable = require('stream').Readable; | ||
var constants = require('constants'); | ||
Writable = require('stream').Writable; | ||
Transform = require('stream').Transform; | ||
EventEmitter = require("events").EventEmitter; | ||
fs = require('fs'); | ||
constants = require('constants'); | ||
Responder = (function(superClass) { | ||
var Responder = (function(superClass) { | ||
extend(Responder, superClass); | ||
@@ -61,3 +55,3 @@ | ||
DirectoryEmitter = (function(superClass) { | ||
var DirectoryEmitter = (function(superClass) { | ||
extend(DirectoryEmitter, superClass); | ||
@@ -97,3 +91,3 @@ | ||
ContextWrapper = (function() { | ||
var ContextWrapper = (function() { | ||
function ContextWrapper(ctx1, server) { | ||
@@ -123,3 +117,3 @@ this.ctx = ctx1; | ||
module.exports = SFTPServer = (function(superClass) { | ||
var SFTPServer = (function(superClass) { | ||
extend(SFTPServer, superClass); | ||
@@ -166,3 +160,5 @@ | ||
Statter = (function() { | ||
module.exports = SFTPServer | ||
var Statter = (function() { | ||
function Statter(sftpStream1, reqid1) { | ||
@@ -211,3 +207,3 @@ this.sftpStream = sftpStream1; | ||
SFTPFileStream = (function(superClass) { | ||
var SFTPFileStream = (function(superClass) { | ||
extend(SFTPFileStream, superClass); | ||
@@ -225,3 +221,3 @@ | ||
SFTPSession = (function(superClass) { | ||
var SFTPSession = (function(superClass) { | ||
extend(SFTPSession, superClass); | ||
@@ -424,3 +420,3 @@ | ||
SFTPSession.prototype.CLOSE = function(reqid, handle) { | ||
return this.sftpStream.status(reqid, ssh2.SFTP_STATUS_CODE.OK); | ||
//return this.sftpStream.status(reqid, ssh2.SFTP_STATUS_CODE.OK); | ||
if (this.handles[handle]) { | ||
@@ -437,3 +433,3 @@ switch (this.handles[handle].mode) { | ||
this.handles[handle].stream.push(null); | ||
delete this.handles[handle]; | ||
//delete this.handles[handle]; //can't delete it while it's still going, right? | ||
return this.sftpStream.status(reqid, ssh2.SFTP_STATUS_CODE.OK); | ||
@@ -440,0 +436,0 @@ default: |
{ | ||
"name": "node-sftp-server", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Node.js SFTP Server bindings to implement your own SFTP Server", | ||
@@ -5,0 +5,0 @@ "main": "node-sftp-server.js", |
@@ -32,3 +32,3 @@ | ||
This returns a new `SFTPServer()` object, which is an EventEmitter. If the private | ||
key is not specified, the constructor will try to use `ssh_host_rsa_key`. | ||
key is not specified, the constructor will try to use `ssh_host_rsa_key` in the current directory. | ||
@@ -62,3 +62,3 @@ ### methods | ||
`.on("realpath",path,callback)` - the server wants to determine the 'real' path | ||
`.on("realpath",function (path,callback) { })` - the server wants to determine the 'real' path | ||
for some user. For instance, if a user, when they log in, is immediately deposited | ||
@@ -69,8 +69,8 @@ into `/home/<username>/` - you could implement that here. Invoke the callback | ||
`.on("stat",path,statkind,statresponder)` - on any of STAT, LSTAT, or FSTAT | ||
`.on("stat",function (path,statkind,statresponder) { })` - on any of STAT, LSTAT, or FSTAT | ||
requests (the type will be passed in "statkind"). Return the status using | ||
`statresponder({mode: , uid:, gid: size: atime:, mtime: })`. Or use any of the | ||
error methods in ##Error Callbacks below | ||
error methods in [Error Callbacks](#error-callbacks) below | ||
`.on("readdir",path,directory_emitter)` - on a directory listing attempt, the | ||
`.on("readdir",function (path,directory_emitter) { })` - on a directory listing attempt, the | ||
directory_emitter will keep emitting `dir` messages with a `responder` as a | ||
@@ -81,10 +81,10 @@ parameter, allowing you to respond with `responder.file(filename)` to return | ||
`.on("readfile",path,writable_stream)` - the client is attempting to read a file | ||
`.on("readfile",function (path,writable_stream) { })` - the client is attempting to read a file | ||
from the server - place or pipe the contents of the file into the `writable_stream`. | ||
`.on("writefile",path,readable_stream)` - the client is attempting to write a | ||
`.on("writefile",function (path,readable_stream) { })` - the client is attempting to write a | ||
file to the server - the `readable_stream` corresponds to the actual file. You | ||
may `.pipe()` that into a writable stream of your own, or use it directly. | ||
`.on("delete",path,callback)` - the client wishes to delete a file. Respond with | ||
`.on("delete",function (path,callback) { })` - the client wishes to delete a file. Respond with | ||
`callback.ok()` or `callback.fail()` or any of the other error types | ||
@@ -91,0 +91,0 @@ |
@@ -48,4 +48,6 @@ "use strict"; | ||
return session.on("writefile", function(path, readstream) { | ||
console.warn("WRITE FILE HAS BEEN ATTEMPTED!"); | ||
var something; | ||
something = fs.createWriteStream("/tmp/garbage"); | ||
readstream.on("end",function() {console.warn("Writefile request has come to an end!!!")}); | ||
return readstream.pipe(something); | ||
@@ -52,0 +54,0 @@ }); |
2130958
9
434