joeftp

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 7 Imported by: 0

README

joeftp

joeftp - a golang FTP and FTPS Client Library that implements a FTP client described in RFC 959 and 4217

A simple library to allow client access to FTP server

see

Current FTP commands supported

  • USER <username>
  • PASS <password>
  • QUIT
  • TYPE <type-code>
  • RETR <pathname>
  • STOR <pathname>
  • DELE <pathname>
  • LIST
  • SITE <string>
  • STAT <pathname>

Sample code

package main

import (
	"fmt"
	"github.com/CalypsoSys/joeftp"
)

func main() {
	fmt.Printf("Testing JoeFtp\n")

	ftp := joeftp.JoeFtp{Host: "ftp.cs.brown.edu", Port: 21, DebugMode: true}
	defer ftp.Close()

	ftp.Connect("ftp.cs.brown.edu", 21, true)
	ftp.LogonAnonymous()
	ftp.List()

	ftp.Quit()
}

Documentation

Overview

Package joeftp implements a FTP client descrive in RFC 959

see https://www.ietf.org/rfc/rfc959.txt

https://www.ietf.org/rfc/rfc2428.txt
https://www.ietf.org/rfc/rfc4217.txt

Currently FTP commands supports ==============================

     Yes - USER <SP> <username> <CRLF>
	Yes - PASS <SP> <password> <CRLF>
	No  - ACCT <SP> <account-information> <CRLF>
	No  - CWD  <SP> <pathname> <CRLF>
	No  - CDUP <CRLF>
	No  - SMNT <SP> <pathname> <CRLF>
	Yes - QUIT <CRLF>
	No  - REIN <CRLF>
	No  - PORT <SP> <host-port> <CRLF>
	No  - PASV <CRLF>
	Yes - TYPE <SP> <type-code> <CRLF>
	No  - STRU <SP> <structure-code> <CRLF>
	No  - MODE <SP> <mode-code> <CRLF>
	Yes - RETR <SP> <pathname> <CRLF>
	Yes - STOR <SP> <pathname> <CRLF>
	No  - STOU <CRLF>
	No  - APPE <SP> <pathname> <CRLF>
	No  - ALLO <SP> <decimal-integer>
		[<SP> R <SP> <decimal-integer>] <CRLF>
	No  - REST <SP> <marker> <CRLF>
	No  - RNFR <SP> <pathname> <CRLF>
	No  - RNTO <SP> <pathname> <CRLF>
	No  - ABOR <CRLF>
	Yes - DELE <SP> <pathname> <CRLF>
	No  - RMD  <SP> <pathname> <CRLF>
	No  - MKD  <SP> <pathname> <CRLF>
	Yes - PWD  <CRLF>
	Yes - LIST [<SP> <pathname>] <CRLF>
	No  - NLST [<SP> <pathname>] <CRLF>
	Yes - SITE <SP> <string> <CRLF>
	No  - SYST <CRLF>
	Yes - STAT [<SP> <pathname>] <CRLF>
	No  - HELP [<SP> <string>] <CRLF>
	No  - NOOP <CRLF>

	Non Passive command
        ABOR, ALLO, DELE, CWD, CDUP, SMNT, HELP, MODE, NOOP, PASV,
		QUIT, SITE, PORT, SYST, STAT, RMD, MKD, PWD, STRU, and TYPE.

	Commands that require passive
		APPE, LIST, NLST, REIN, RETR, STOR, and STOU.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JoeFtp

type JoeFtp struct {
	Host                  string
	Port                  int
	Timeout               time.Duration
	FTPS                  bool
	ExtendedPassive       bool
	DebugMode             bool
	TlsInsecureSkipVerify bool
	TlsMinVersion         uint16
	// contains filtered or unexported fields
}

JoeFtp structure to control access to a FTP server

func (*JoeFtp) Close

func (ftp *JoeFtp) Close() error

Close close the extablished tcp connection to the FTP server

func (*JoeFtp) Connect

func (ftp *JoeFtp) Connect() (int, string, error)

Connect creates a TCP connection to a FTP server specifed by host:port

func (*JoeFtp) DeleteFile

func (ftp *JoeFtp) DeleteFile(fileName string) (int, string, error)

DeleteFile This command causes the specifed file deleted from the FTP site used FTP commands: DELE

func (*JoeFtp) List

func (ftp *JoeFtp) List() (int, string, []byte, error)

List This command retries the current "list" for files to be transfered to the client used FTP commands: LIST & PASV

func (*JoeFtp) Logon

func (ftp *JoeFtp) Logon(userName string, password string) (int, string, error)

Logon login to the specified FTP server using the supplied credentials used FTP commands: USER and PASS

func (*JoeFtp) LogonAnonymous

func (ftp *JoeFtp) LogonAnonymous() (int, string, error)

LogonAnonymous login to the specified FTP server using the anonymous user (no password) used FTP commands: USER

func (*JoeFtp) Quit

func (ftp *JoeFtp) Quit() (int, string, error)

Quit This command terminated the FTP connection used FTP commands: QUIT

func (*JoeFtp) RetreiveFile

func (ftp *JoeFtp) RetreiveFile(fileName string) (int, string, []byte, error)

RetreiveFile This command causes the specifed file to be retrieved from the FTP site used FTP commands: RETR & PASV

func (*JoeFtp) SendCommand

func (ftp *JoeFtp) SendCommand(command string) (int, string, error)

SendCommand send a command to the FTP server

func (*JoeFtp) Site

func (ftp *JoeFtp) Site(parameters string) (int, string, error)

Site This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol.

used FTP commands: SITE

func (*JoeFtp) Stat

func (ftp *JoeFtp) Stat() (int, string, error)

Stat This command shall cause a status response to be sent over the control connection in the form of a reply. used FTP commands: STAT

func (*JoeFtp) StoreBytes

func (ftp *JoeFtp) StoreBytes(fileName string, data []byte) (int, string, []byte, error)

StoreBytes This command shall causes the specified byte stream to be transfered to the FTP server to a file used FTP commands: STOR & PASV

func (*JoeFtp) StoreFile

func (ftp *JoeFtp) StoreFile(fileName string, filePath string) (int, string, []byte, error)

StoreFile This command shall causes the specified file to be transfered to the FTP server used FTP commands: STOR & PASV

func (*JoeFtp) Type

func (ftp *JoeFtp) Type(parameters string) (int, string, error)

Type This command sets the data storage representation A = ASCII, E = EBCDIC, I = Binary (image) used FTP commands: TYPE

Jump to

Keyboard shortcuts

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