README
SMB2 Client for Node.js
Introduction
This library is a simple implementation of SMB2 for Node.js. It allows you to access a SMB2 share as if you were using the native fs library.
The development is still at an experimental stage and should not be yet considered for production environment.
Installation
npm install -S @codetakeo/smb2
API
Asynchronicity
All async methods can be used with Node-style callbacks or return promises if none is passed:
// Node-style callback
smb2Client.readFile('foo.txt', function(err, content) {
if (err) throw err;
console.log(content);
});
// With promise, ideal with ES2017 async functions
const content = await smb2Client.readFile('foo.txt');
console.log(content);
Construction
var smb2Client = new SMB2 ( options )
The SMB2 class is the constructor of your SMB2 client.
the parameter options
accepts this list of attributes:
share
: the share you want to accessdomain
: the domain of which the user is registeredusername
: the username of the user that access the sharepassword
: the passwordport
(optional): default445
, the port of the SMB serversocket
(optional): defaultnew net.Socket (from NodeJS Core)
, the socket used for communication with the SMB ServerpacketConcurrency
(optional): default20
, the number of simultaneous packet when writing / reading data from the shareautoCloseTimeout
(optional): default10000
, the timeout in milliseconds before to close the SMB2 session and the socket, if set to0
the connection will never be closed unless you do it
Example:
// load the library
var SMB2 = require('@codetakeo/smb2');
// create an SMB2 instance
var smb2Client = new SMB2({
share: '\\\\000.000.000.000\\c