Giter Club home page Giter Club logo

ringo-ftpserver's Introduction

#ringo-ftpserver

About

ringo-ftpserver is a lightweight Javascript wrapper around Apache FtpServer which allows embedding an FTP server in RingoJS applications with a few lines of code.

Status

Although Apache FtpServer is a mature piece of software, ringo-ftpserver itself should currently be considered beta.

License

Apache License, Version 2.0

Installation

If rp is installed, simply type rp install ringo-ftpserver to install the latest version.

To manually install it unzip the contents of the distribution archive into the packages directory inside the RingoJS home directory. Alternatively you can place it anywhere outside and create a symbolic link inside the packages directory or use the -m switch while starting ringo and add the path to your desired module-directory.

Standalone Server

ringo-ftpserver contains a main.js script suitable for starting a standalone FTP server. Assumed that RingoJS' bin directory is part of the PATH, simply start it with the following command:

ringo path/to/ringo-ftpserver/main.js

Calling the main script without any arguments displays the available configuration options. The only required argument is the path to a JSON file containing the user accounts. ringo-ftpserver comes with an example users.json file containing a test account (username: test, password: test). Note that the home directory of the test user will probably not exist in your setup, so you might want to adapt that.

ringo path/to/ringo-ftpserver/main.js -p 2100 path/to/ringo-ftpserver/users.json

User management

ringo-ftpserver uses a custom user manager that reads account data from a provided JSON file that contains an array of objects defining the available FTP accounts. Since the user manager expects account passwords to be salted/hashed, ringo-ftpserver contains a command line script for managing user accounts:

ringo path/to/ringo-ftpserver/users.js

Embedding

Using ringo-ftpserver in an application is a matter of a few lines of code:

// require the FtpServer module
var {FtpServer} = require("ringo-ftpserver");

// create a listener
var listener = FtpServer.createListener();
// create a user manager on top of the JSON file 
// or javascript object containing the user accounts
var file = module.resolve("./users.json");
var usermanager = FtpServer.createUserManager(file);

// create the server and start it
var server = new FtpServer(listener, usermanager);
server.start();

Listener options

FtpServer.createListener() accepts an object passed as argument with the following properties:

  • port: The port to listen on (defaults to 21)
  • sslConfig: If using encryption, this property must contain the configuration object
  • useImplictSsl: If boolean true the server uses implicit SSL encryption, otherwise explicit

Encryption

To use SSL/TLS encryption with ringo-ftpserver, create an SSL configuration as follows:

var sslConfig = FtpServer.createSslConfig(options);
  • keystore: The path to the Java keystore file containing the server certificate
  • password: The password of the keystore (optional)
  • protocol: The protocol to use for encryption (either ssl or tls, defaults to the latter)

Pass the configuration object as option to the listener creation function (see above).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.