Socket
Socket
Sign inDemoInstall

ftp-generate-response

Package Overview
Dependencies
0
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ftp-generate-response

Generate RFC conforming response strings for an FTP server.


Version published
Weekly downloads
5
decreased by-16.67%
Maintainers
2
Install size
6.25 kB
Created
Weekly downloads
 

Readme

Source

ftp-generate-response

Generate RFC conforming strings for an FTP server connection.

Install the normal node way.

Use like this:

var generate = require('ftp-generate-response')
var lines = [
	'Welcome to the server.',
	'Contact an admin for help.',
	'Vist the IRC at #our-site'
]
var output = generate(220, lines)

For which the expected output would be:

220-Welcome to the server
 Contact an admin for help.
220 Visit the IRC at #our-site

It is possible to specify a different string to prepend multi-line strings, e.g. like this:

var generate = require('ftp-generate-response')
var lines = [
	'Welcome to the server.',
	'Contact an admin for help.',
	'Vist the IRC at #our-site'
]
var output = generate(220, lines, '    ')

For which the expected output would be:

220-Welcome to the server
    Contact an admin for help.
220 Visit the IRC at #our-site

Notes on a common style

The following response style is found in many FTP server implementations:

220-Welcome to the server
220-Contact an admin for help.
220 Visit the IRC at #our-site

Strictly speaking, according to the RFC this is not acceptable:

If an intermediary line begins with a 3-digit number, the Server must pad the front to avoid confusion.

The reason the above style is interpreted by clients correctly is because the RFC also states:

The user-process then simply needs to search for the second occurrence of the same reply code, followed by (Space), at the beginning of a line, and ignore all intermediary lines.

This means that the above message would (after parsing) become:

Welcome to the server\r\n220-Contact an admin for help.\r\nVisit the IRC at #our-site

Additionally, although the RFC states that the Server must pad, it is unclear what padding is required. The example in the RFC pads the intermediary lines with <SP><SP>, but does not require it.

Although many FTP clients will interpret the above string correctly, we recommend to not use this style and instead pad with <SP><SP> on all intermediary lines, as shown in the RFC.

Multi-line messages contructed in this way will look like:

220-Welcome to the server
  Contact an admin for help.
220 Visit the IRC at #our-site

Parsing this can trim all <SP> characters at the start of each line, generating the following usable string:

Welcome to the server\r\nContact an admin for help.\r\nVisit the IRC at #our-site

License

VOL

Keywords

FAQs

Last updated on 07 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc