ftpserver

command module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2020 License: MIT Imports: 10 Imported by: 0

README

Golang FTP Server

Build Docker Image Cross Build Docker test Go Report Card GoDoc

This FTP server is a gateway between old-school FTP devices and modern cloud based file systems, using the afero 's Fs interface and acting as a reference implementation of the ftpserverlib

At the current stage, supported backend are:

Planned FS are:

  • Dropbox
  • Google Drive

Current status of the project

Features
FTP protocol

These features are brought by ftpserverlib itself:

  • Uploading and downloading files
  • Directory listing (LIST + MLST)
  • File and directory deletion and renaming
  • TLS support (AUTH + PROT)
  • File download/upload resume support (REST)
  • Complete driver for all the above features
  • Passive socket connections (EPSV and PASV commands)
  • Active socket connections (PORT command)
  • Small memory footprint
  • Only relies on the standard library except for:
  • Supported extensions:
    • AUTH - Control session protection
    • AUTH TLS - TLS session
    • PROT - Transfer protection
    • MDTM - File Modification Time
    • SIZE - Size of a file
    • REST - Restart of interrupted transfer
    • MLST - Simple file listing for machine processing
    • MLSD - Directory listing for machine processing

Getting started

Get it
Golang
go get -u github.com/fclairamb/ftpserver
Config file

If you don't create a ftpserver.json file, it will be created for you.

Here is a sample config file:

{
  "version": 1,
  "accesses": [
    {
      "user": "test",
      "pass": "test",
      "fs": "os",
      "params": {
        "basePath": "/tmp"
      }
    },
    {
      "user": "s3",
      "pass": "s3",
      "fs": "s3",
      "params": {
        "endpoint": "https://s3.amazonaws.com",
        "region": "eu-west-1",
        "bucket": "my-bucket",
        "access_key_id": "AKIA....",
        "secret_access_key": "IDxd....",
        "disable_ssl": "false",
        "path_style": "false"
      }
    },
    {
      "user": "sftp",
      "pass": "sftp",
      "fs": "sftp",
      "params": {
        "username": "user",
        "password": "password",
        "hostname": "192.168.168.11:22"
      }
    }
  ],
  "passive_transfer_port_range": {
    "start": 2122,
    "end": 2130
  }
}
With local binary

You can build the binary and use it directly:

# Get and install the server
go get github.com/fclairamb/ftpserver

ftpserver &

# Download some file
[ -f kitty.jpg ] || (curl -o kitty.jpg.tmp https://placekitten.com/2048/2048 && mv kitty.jpg.tmp kitty.jpg)

# Upload it to the server
curl -v -T kitty.jpg ftp://test:test@localhost:2121/

# Download it back
curl ftp://test:test@localhost:2121/kitty.jpg -o kitty2.jpg

# Compare it
diff kitty.jpg kitty2.jpg
With docker

There's also a containerized version of the server (15MB, based on alpine).

# Starting the sample FTP server
docker run --rm -d -p 2121-2130:2121-2130 ftpserver/ftpserver

# Download some file
[ -f kitty.jpg ] || (curl -o kitty.jpg.tmp https://placekitten.com/2048/2048 && mv kitty.jpg.tmp kitty.jpg)

# Upload it
curl -v -T kitty.jpg ftp://test:test@localhost:2121/

# Download it back
curl ftp://test:test@localhost:2121/kitty.jpg -o kitty2.jpg

# Compare it
diff kitty.jpg kitty2.jpg

Documentation

Overview

ftpserver allows to create your own FTP(S) server

Directories

Path Synopsis
Package config provides all the config management
Package config provides all the config management
confpar
Package confpar provide the core parameters of the config
Package confpar provide the core parameters of the config
fs
Package fs provides all the core features related to file-system access
Package fs provides all the core features related to file-system access
afos
Package afos provide an afero OS FS access layer
Package afos provide an afero OS FS access layer
fslog
Package fslog provides an afero FS logging package
Package fslog provides an afero FS logging package
mail
Package mail provides a mail access layer
Package mail provides a mail access layer
s3
Package s3 provides an AWS S3 access layer
Package s3 provides an AWS S3 access layer
sftp
Package sftp provides an SFTP connection layer
Package sftp provides an SFTP connection layer
stripprefix
Package stripprefix is a file-system abstraction layer to strip a part of the path
Package stripprefix is a file-system abstraction layer to strip a part of the path
Package server contains the core FTP server code
Package server contains the core FTP server code

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL