Merge pull request #16 from trs/fix-secure-check

Fix secure check
This commit is contained in:
Tyler Stewart
2017-05-19 13:01:35 -06:00
committed by GitHub
8 changed files with 44 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
![ftp-srv](logo.png)
[![ftp-srv](logo.png)](https://github.com/trs/ftp-srv)
[![npm version](https://badge.fury.io/js/ftp-srv.svg)](https://badge.fury.io/js/ftp-srv) [![Build Status](https://travis-ci.org/trs/ftp-srv.svg?branch=master)](https://travis-ci.org/trs/ftp-srv) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

12
logo-generate.js Normal file
View File

@@ -0,0 +1,12 @@
const fs = require('fs');
const htmlConvert = require('html-convert');
const convert = htmlConvert();
let ws = fs.createWriteStream('logo.png');
let rs = convert('./logo.html', {
width: 350,
height: 90
});
rs.pipe(ws);
ws.on('finish', () => process.exit());

View File

@@ -2,42 +2,45 @@
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style>
body {
padding: 0px;
padding: 0;
margin: 0;
}
h1 {
display: flex;
margin: 0;
padding: 0;
font-size: 73px;
padding: 0 2px;
font-size: 70px;
font-family: 'Source Code Pro', monospace;
font-weight: bold;
line-height: 0.9em;
letter-spacing: -3px;
color: #444;
text-shadow:
1px 0px 1px #ccc, 0px 1px 1px #eee,
2px 1px 1px #ccc, 1px 2px 1px #eee,
3px 2px 1px #ccc, 2px 3px 1px #eee,
4px 3px 1px #ccc, 3px 4px 1px #eee,
5px 4px 1px #ccc, 4px 5px 1px #eee,
6px 5px 1px #ccc, 5px 6px 1px #eee,
7px 6px 1px #ccc;
color: #333;
-webkit-font-smoothing: antialiased;
text-shadow:
1px 0px 0px #ccc, 0px 1px 0px #eee,
2px 1px 0px #ccc, 1px 2px 0px #eee,
3px 2px 0px #ccc, 2px 3px 0px #eee,
4px 3px 0px #ccc, 3px 4px 0px #eee,
5px 4px 0px #ccc, 4px 5px 0px #eee,
6px 5px 0px #ccc, 5px 6px 0px #eee,
7px 6px 0px #ccc;
}
h1 > i {
font-size: 42px !important;
font-size: 40px !important;
color: #03A9F4;
align-self: center;
padding-top: 15px;
letter-spacing: 2px;
}
</style>
</head>
<body>
<h1><i class="material-icons">markunread_mailbox</i>ftp-srv</h1>
<h1>
<i class="fa fa-paper-plane"></i>
<span>ftp-srv</span>
</h1>
</body>
</html>

View File

@@ -64,6 +64,7 @@
"eslint-config-google": "0.7.1",
"eslint-plugin-node": "3.0.5",
"ftp": "^0.3.10",
"html-convert": "^2.1.7",
"husky": "0.13.1",
"istanbul": "0.4.5",
"mocha": "3.2.0",

View File

@@ -1,7 +1,7 @@
module.exports = {
directive: 'PBSZ',
handler: function ({command} = {}) {
if (!this.server._tls || !this.secure) return this.reply(202, 'Not suppored');
if (!this.secure) return this.reply(202, 'Not suppored');
this.bufferSize = parseInt(command.arg, 10);
return this.reply(200, this.bufferSize === 0 ? 'OK' : 'Buffer too large: PBSZ=0');
},

View File

@@ -3,7 +3,7 @@ const _ = require('lodash');
module.exports = {
directive: 'PROT',
handler: function ({command} = {}) {
if (!this.server._tls || !this.secure) return this.reply(202, 'Not suppored');
if (!this.secure) return this.reply(202, 'Not suppored');
if (!this.bufferSize && typeof this.bufferSize !== 'number') return this.reply(503);
switch (_.toUpper(command.arg)) {

View File

@@ -7,8 +7,7 @@ describe(CMD, function () {
let sandbox;
const mockClient = {
reply: () => when.resolve(),
server: {},
secure: true
server: {}
};
const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient);
@@ -31,6 +30,7 @@ describe(CMD, function () {
});
it('// successful', done => {
mockClient.secure = true;
mockClient.server._tls = {};
cmdFn({command: {arg: '0'}})
@@ -43,6 +43,7 @@ describe(CMD, function () {
});
it('// successful', done => {
mockClient.secure = true;
mockClient.server._tls = {};
cmdFn({command: {arg: '10'}})

View File

@@ -7,8 +7,7 @@ describe(CMD, function () {
let sandbox;
const mockClient = {
reply: () => when.resolve(),
server: {},
secure: true
server: {}
};
const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient);
@@ -32,6 +31,7 @@ describe(CMD, function () {
it('// unsuccessful - no bufferSize', done => {
mockClient.server._tls = {};
mockClient.secure = true;
cmdFn({command: {arg: 'P'}})
.then(() => {
@@ -43,6 +43,7 @@ describe(CMD, function () {
it('// successful', done => {
mockClient.bufferSize = 0;
mockClient.secure = true;
cmdFn({command: {arg: 'p'}})
.then(() => {
@@ -53,6 +54,7 @@ describe(CMD, function () {
});
it('// unsuccessful - unsupported', done => {
mockClient.secure = true;
cmdFn({command: {arg: 'C'}})
.then(() => {
expect(mockClient.reply.args[0][0]).to.equal(536);
@@ -62,6 +64,7 @@ describe(CMD, function () {
});
it('// unsuccessful - unknown', done => {
mockClient.secure = true;
cmdFn({command: {arg: 'QQ'}})
.then(() => {
expect(mockClient.reply.args[0][0]).to.equal(504);