Skip to content

gonzalop/ftp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

100 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FTP Library for Go

Go Reference Tests Go Report Card License: MIT License: Unlicense

A production-ready FTP library for Go providing both client and server implementations with extensive RFC compliance, TLS support, and modern extensions.

📦 Quick Links

Installation

# Client library
go get github.com/gonzalop/ftp

# Server library
go get github.com/gonzalop/ftp/server

Quick Start

Client Example

package main

import (
    "log"
    "github.com/gonzalop/ftp"
)

func main() {
    // Connect to server (handles ftp, ftps, ftp+explicit)
    // and automatically logs in (default: anonymous)
    client, _ := ftp.Connect("ftp://ftp.example.com")
    defer client.Quit()

    // Upload file
    client.UploadFile("local.txt", "remote.txt")

    // Download file
    client.DownloadFile("remote.txt", "download.txt")
}

→ See full client documentation

Server Example

package main

import (
    "log"
    "github.com/gonzalop/ftp/server"
)

func main() {
    // Start a standard server on port 21 serving files from /var/ftp
    log.Println("FTP server listening on :21")
    log.Fatal(server.ListenAndServe(":21", "/var/ftp"))
}

→ See full server documentation

Features

Client Features

  • TLS/FTPS - Both explicit (AUTH TLS) and implicit modes
  • Bandwidth Limiting - Control upload/download speeds with configurable rate limits
  • Automatic Keep-Alive - Prevents timeouts during idle periods or long transfers
  • Debug Logging - Structured logging with log/slog for easier debugging
  • Progress Tracking - Built-in callbacks for upload/download progress
  • File Operations - Upload, download, append, store unique (STOU), delete, rename
  • Directory Operations - Create, delete, recursive remove, walk directory trees
  • Resume Transfers - Resume interrupted downloads/uploads (REST)
  • Modern Extensions - MLST/MLSD, SIZE, MDTM, HASH support
  • IPv6 Support - Full IPv6 via EPSV/EPRT (RFC 2428)
  • Rich Errors - Detailed protocol error context
  • Transport-Agnostic - Pluggable dialer interface for alternative transports (QUIC, Unix sockets, etc.). See examples/quic for a working implementation.

→ Full feature list and API reference

Server Features

  • Pluggable Backends - Filesystem, S3, memory, or custom storage
  • Bandwidth Limiting - Global and per-user rate limits for transfer control
  • Audit Logging - Comprehensive logging for security-relevant operations
  • Graceful Shutdown - Stop accepting connections and wait for active transfers
  • TLS/FTPS - Explicit and implicit FTPS support
  • Virtual Hosting - HOST command for multi-tenant setups (RFC 7151)
  • File Hashing - HASH command with SHA-256, SHA-512, MD5, CRC32
  • IP-Based Access Control - Authenticate with client IP for security policies
  • Secure by Default - Built-in path validation and chroot support
  • Extensible - Custom authentication and driver interfaces
  • Transport-Agnostic - Pluggable listener factory for alternative transports (QUIC, Unix sockets, etc.). See examples/quic for a working implementation.
  • Command Control - Disable specific commands (i.e.,for security or transport compatibility)

→ Full server documentation

RFC Compliance

Both client and server implement modern FTP standards:

  • RFC 959 - File Transfer Protocol (base)
  • RFC 2389 - Feature Negotiation (FEAT)
  • RFC 2428 - IPv6 and NAT Extensions (EPSV/EPRT)
  • RFC 3659 - Extensions (MLST/MLSD, SIZE, MDTM, REST)
  • RFC 4217 - Securing FTP with TLS
  • RFC 5797 - FTP Command Registry
  • RFC 7151 - File Transfer Protocol HOST Command

Detailed compliance matrices:

Documentation

License

This software is available under 2 licenses -- choose whichever you prefer:

  1. MIT License
  2. Public Domain (Unlicense)

See LICENSE for details.

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

About

A production-ready FTP client and server library with comprehensive TLS support, a developer-friendly API and zero dependencies.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors