Skip to content

Commit

Permalink
Fixes and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Guichaguri committed Oct 7, 2017
1 parent 93e6b21 commit f5a3f0c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.idea/
build/
run/
out/
gradle/
gradlew
gradlew.bat
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# MinimalFTP [![Build Status](https://travis-ci.org/Guichaguri/MinimalFTP.svg?branch=master)](https://travis-ci.org/Guichaguri/MinimalFTP)
A lightweight, simple FTP server. Pure Java, no libraries.

Although it's named "minimal", it supports 53 FTP commands, TLS/SSL, custom file system, custom user authentication, custom commands, etc
## Features
Although it's named "minimal", it supports a bunch of features:

* 100% Java, no libraries
* Lightweight
* Supports 55 FTP commands
* TLS/SSL support
* Custom File System support
* Custom User Authentication support
* Custom Commands support
* Support to obsolete commands (some FTP clients might still use them)

## Specification Support
The required minimum implementation is already done, however, there are still commands that can be implemented.
Expand All @@ -22,29 +32,34 @@ The required minimum implementation is already done, however, there are still co
* [RFC 4217](https://tools.ietf.org/html/rfc4217) - Securing FTP with TLS
* [RFC 5797](https://tools.ietf.org/html/rfc5797) - FTP Command and Extension Registry
* [RFC 7151](https://tools.ietf.org/html/rfc7151) - File Transfer Protocol HOST Command for Virtual Hosts (0/1)
* [draft-somers-ftp-mfxx-04](https://tools.ietf.org/html/draft-somers-ftp-mfxx-04) The "MFMT", "MFCT", and "MFF" Command Extensions for FTP (1/3)
* [draft-twine-ftpmd5-00](https://tools.ietf.org/html/draft-twine-ftpmd5-00) - The "MD5" and "MMD5" FTP Command Extensions (1/2) (Obsolete)
* [draft-somers-ftp-mfxx-04](https://tools.ietf.org/html/draft-somers-ftp-mfxx-04) - The "MFMT", "MFCT", and "MFF" Command Extensions for FTP (1/3)
* [draft-bryan-ftpext-hash-02](https://tools.ietf.org/html/draft-bryan-ftpext-hash-02) - File Transfer Protocol HASH Command for Cryptographic Hashes (1/1)
* [draft-bryan-ftp-range-08](https://tools.ietf.org/html/draft-bryan-ftp-range-08) - File Transfer Protocol RANG Command for Octet Ranges (0/1)

# Usage

### Dependency
MinimalFTP is published on JCenter and Maven Central

#### Maven
```xml
<dependency>
<groupId>com.guichaguri</groupId>
<artifactId>minimalftp</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<type>pom</type>
</dependency>
```

#### Gradle
```groovy
compile 'com.guichaguri:minimalftp:1.0.3'
compile 'com.guichaguri:minimalftp:1.0.4'
```

#### Ivy
```xml
<dependency org='com.guichaguri' name='minimalftp' rev='1.0.3'>
<dependency org='com.guichaguri' name='minimalftp' rev='1.0.4'>
<artifact name='minimalftp' ext='pom' />
</dependency>
```
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.guichaguri'
version '1.0.3'
version '1.0.4'

buildscript {
repositories {
Expand All @@ -26,20 +26,20 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}

def publishSettings = new Properties()
def propFile = file('publish.properties');
if(propFile.exists()) {
publishSettings.load(new FileInputStream(propFile))
}

bintray {
def publishSettings = new Properties()
def propFile = file('publish.properties')
if(propFile.exists()) {
publishSettings.load(new FileInputStream(propFile))
}

user = publishSettings.bintray_user
key = publishSettings.bintray_key
publications = ['MavenBuild']
pkg {
repo = 'maven'
name = 'MinimalFTP'
licenses = ['GPL-3.0']
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/Guichaguri/MinimalFTP.git'

version {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/guichaguri/minimalftp/FTPConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,14 @@ protected void site(String cmd) {
* FEAT command
*/
protected void feat() {
String list = "";
StringBuilder list = new StringBuilder();
list.append("- Supported Features:\r\n");

for(String feat : features) {
list += feat + "\r\n";
list.append(' ').append(feat).append("\r\n");
}

sendResponse(211, "- Supported Features:\r\n" + list);
sendResponse(211, list.toString());
sendResponse(211, "End");
}

Expand All @@ -486,7 +488,6 @@ protected void opts(String[] opts) {

if(!options.containsKey(option)) {
sendResponse(501, "No option found");
return;
} else if(opts.length < 2) {
sendResponse(200, options.get(option));
} else {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/guichaguri/minimalftp/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public static <F> String getPermission(IFileSystem<F> fs, F file) {
}

public static <F> String getFacts(IFileSystem<F> fs, F file, String[] options) {
// Intended Format
// modify=20170808052431;size=7045120;type=file;perm=rfadw; video.mp4
// modify=20170526215012;size=380;type=file;perm=rfadw; data.txt
// modify=20171012082146;size=0;type=dir;perm=elfpcm; directory

String facts = "";
boolean dir = fs.isDirectory(file);

Expand Down Expand Up @@ -158,7 +163,7 @@ public static void write(OutputStream out, byte[] bytes, int len, boolean ascii)
}

public static <F> InputStream readFileSystem(IFileSystem<F> fs, F file, long start, boolean ascii) throws IOException {
if(ascii) {
if(ascii && start > 0) {
InputStream in = new BufferedInputStream(fs.readFile(file, 0));
long offset = 0;

Expand Down

0 comments on commit f5a3f0c

Please sign in to comment.