vort

package module
v0.0.0-...-92a4403 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 21 Imported by: 0

README

Build Status GoDoc

Vort-ftprelay

This is part of the Vort project.

vort-ftprelay provides access to vort files and vort fileservers through a FTP server. Vort-relay starts an ftp server, that you connect to. Your requests for files are translated to the native vort protocol.

You will get much better performance from the command line client, or the native filesystem mount. This relay is provided for situations where neither of those will work for you.

Installation

Windows

Download Vort

Linux and MacOSX

Install google's go language, then:

go get github.com/donomii/Vort
go build github.com/donomii/Vort/vort/vort.go

Command Line Examples

Start Vort with the default options

vort

Connect to a network share

	vort.exe --type=http --repo=http://localhost:80/

Open a vort file

vort myfiles.vort

Start Vort with encryption

vort --encrypt=1 --key="a 32-byte key123a 32-byte key123"

Connect to Vort with an ftp client

 ftp localhost 8021

Create and open a sqlite type store

vort --type=sqlite myfiles.vort

Create and open a file blocks type store

vort --type=files myfiles.vort	

Accessing Vort

Vort provides access to your vort file store through a local FTP server. Vort will print the url of the server, after it starts up.

You can access this url through normal FTP clients, including:

Web browsers in FTP mode

Most web browsers include an ftp client. If you have Microsoft Edge, Firefox or Chrome, just paste the vort url into the address bar to access your files.

FTP "drive" mount

Windows has built in support for using FTP servers as ordinary drives. In a file explorer window, click on your computer, then find "Map network drive" somewhere in the menu. Follow the instructions to connect to your vort file.

Linux can also mount FTP drives, but it requires installing software and some fiddling about on the command line.

Stand alone FTP clients

There are a large selection of FTP clients for every platform, and they should all work with Vort.

Store types

Vort supports many different formats, which allows me to test many different storage techniques. There are currently three useful ones

SQLite

vort can use a single-file sqlite database as a file store. This is the best option if you want to send your vort store to someone else, upload it to a server, or otherwise move it around.

It tends to slow down after you put ~100Gb into it, so if you want to store something bigger, try the files store.

vort --type=sqlite myfiles.vort

Note: you only have to specify the type once, when creating your vort file. vort will autodetect the store type of an existing file.

Files

vort keeps its data in ordinary files. This is probably slower than sqlite, but can handle almost any amount of data without slowing down (as much). This is normally the best option for network servers (it is the default for vort-nfs).

vort --type=files myfiles.vort

Note: you only have to specify the type once, when creating your vort directory. vort will autodetect the type of an existing file.

http

Technically not a file store, the http driver connects to a vort network share, and accesses the data on the server.

vort --type=http --repo=http://myserver.localnet/

The slash on the end is required, for now.

Encryption

Warning: Vort uses strong encryption. If you lose your encryption key, you will never be able to access your files again.

Vort uses symmetric key encryption, so in order to access your encrypted filesystem, you must remember the key you created, and type it in every time you open Vort. If you forget or lose your key, all your files are gone forever. They are never coming back. Using encryption is entirely at your own risk, and I am not responsible in any way for any data loss or leak due to using encryption.

Disclaimer

Actually, I'm not responsible at all for any problems caused by using this software. It is open source, you're getting it for free, and if it doesn't work you're entitled to a full refund and nothing more.

Documentation

Overview

An experimental FTP server framework. By providing a simple driver class that responds to a handful of methods you can have a complete FTP server.

Some sample use cases include persisting data to an Amazon S3 bucket, a relational database, redis or memory.

There is a sample in-memory driver available - see the documentation for the graval-mem package or the graval READEME for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDirItem

func NewDirItem(name string, size int64, modtime time.Time) os.FileInfo

NewDirItem creates a new os.FileInfo that represents a single diretory. Use this function to build the response to DirContents() in your FTPDriver implementation.

func NewFileItem

func NewFileItem(name string, bytes int64, modtime time.Time) os.FileInfo

NewFileItem creates a new os.FileInfo that represents a single file. Use this function to build the response to DirContents() in your FTPDriver implementation.

Types

type BoundCommand

type BoundCommand struct {
	CmdObj ftpCommand
	Param  string
}

type CryptoConfig

type CryptoConfig struct {
	Implicit  bool
	Force     bool
	TlsConfig *tls.Config
}

type FTPDriver

type FTPDriver interface {
	// params  - username, password
	// returns - true if the provided details are valid
	Authenticate(username string, password string) bool

	// params  - a file path
	// returns - an int with the number of bytes in the file or -1 if the file
	//           doesn't exist
	Bytes(path string) int64

	// params  - a file path
	// returns - a time indicating when the requested path was last modified
	//         - an ok flag if the file doesn't exist or the user lacks
	//           permissions
	ModifiedTime(path string) (time.Time, bool)

	// params  - path
	// returns - true if the current user is permitted to change to the
	//           requested path
	ChangeDir(path string) bool

	// params  - path
	// returns - a collection of items describing the contents of the requested
	//           path
	DirContents(path string) ([]os.FileInfo, bool)

	// params  - path
	// returns - true if the directory was deleted
	DeleteDir(path string) bool

	// params  - path
	// returns - true if the file was deleted
	DeleteFile(path string) bool

	// params  - fromPath, toPath
	// returns - true if the file was renamed
	Rename(fromPath string, toPath string) bool

	// params  - path
	// returns - true if the new directory was created
	MakeDir(path string) bool

	// params  - path, position
	// returns - a string containing the file data to send to the client
	GetFile(path string, position int64) (io.ReadCloser, bool)

	// params  - desination path, an io.Reader containing the file data
	// returns - true if the data was successfully persisted
	PutFile(path string, reader io.Reader) bool
}

You will create an implementation of this interface that speaks to your chosen persistence layer. graval will create a new instance of your driver for each client that connects and delegate to it as required.

type FTPDriverFactory

type FTPDriverFactory interface {
	NewDriver() (FTPDriver, error)
}

For each client that connects to the server, a new FTPDriver is required. Create an implementation if this interface and provide it to FTPServer.

type FTPDriverSetRemoteAddress

type FTPDriverSetRemoteAddress interface {
	SetRemoteAddress(remoteAddress net.Addr)
}

FTPDriverSetRemoteAddress is an optional interface for setting remote address

type FTPServer

type FTPServer struct {
	// contains filtered or unexported fields
}

FTPServer is the root of your FTP application. You should instantiate one of these and call ListenAndServe() to start accepting client connections.

Always use the NewFTPServer() method to create a new FTPServer.

func NewFTPServer

func NewFTPServer(opts *FTPServerOpts) *FTPServer

NewFTPServer initialises a new FTP server. Configuration options are provided via an instance of FTPServerOpts. Calling this function in your code will probably look something like this:

factory := &MyDriverFactory{}
server  := graval.NewFTPServer(&graval.FTPServerOpts{ Factory: factory })

or:

factory := &MyDriverFactory{}
opts    := &graval.FTPServerOpts{
  Factory: factory,
  Port: 2000,
  Hostname: "127.0.0.1",
}
server  := graval.NewFTPServer(opts)

func (*FTPServer) Close

func (ftpServer *FTPServer) Close() error

func (*FTPServer) ListenAndServe

func (ftpServer *FTPServer) ListenAndServe() error

ListenAndServe asks a new FTPServer to begin accepting client connections. It accepts no arguments - all configuration is provided via the NewFTPServer function.

If the server fails to start for any reason, an error will be returned. Common errors are trying to bind to a privileged port or something else is already listening on the same port.

type FTPServerOpts

type FTPServerOpts struct {
	// Server name will be used for welcome message
	ServerName string

	// The factory that will be used to create a new FTPDriver instance for
	// each client connection. This is a mandatory option.
	Factory FTPDriverFactory

	// The hostname that the FTP server should listen on. Optional, defaults to
	// "::", which means all hostnames on ipv4 and ipv6.
	Hostname string

	// The port that the FTP should listen on. Optional, defaults to 3000. In
	// a production environment you will probably want to change this to 21.
	Port int

	// Options for passive data connections
	PassiveOpts *PassiveOpts

	// Options for FTPS and FTPES
	CryptoConfig *CryptoConfig

	// Disable logging (useful for tests)
	Quiet bool
}

serverOpts contains parameters for graval.NewFTPServer()

type PassiveOpts

type PassiveOpts struct {
	ListenAddress string
	NatAddress    string
	PassivePorts  *PassivePorts
}

type PassivePorts

type PassivePorts struct {
	Low  int
	High int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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