fsp

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 12 Imported by: 0

README

fsp

fsp client

fspd

fspd -f fspd.conf -p 9531 -d /tmp -P /tmp/fspd.pid

proxy

set http_proxy=http://127.0.0.1:1080 set https_proxy=http://127.0.0.1:1080

docker

  1. 列出所有容器 docker ps -a -q

  2. 停止所有容器 docker stop $(docker ps -a -q)

  3. 删除所有容器 docker rm $(docker ps -a -q)

  4. 查看镜像 docker images

  5. 删除指定id的镜像 docker rmi

  6. 删除全部镜像 docker rmi $(docker images -q)

  7. 启动容器 docker run -it -p 9531:9531/udp centos /bin/bash docker start 6b407fb8d0b2

  8. 进入容器 docker exec -it 6b407fb8d0b2 /bin/bash docker attach 6b407fb8d0b2

  9. 复制文件到容器 docker cp fspd.conf 6b407fb8d0b2:/tmp/

Documentation

Overview

Package fsp provides a interface for connect fsp server

package main
import (
	"github.com/finove/fsp"
	"fmt"
)

func main() {
	var err error
	var fspSession *fsp.Session
	fspSession, err = fsp.NewSession("127.0.0.1:21", "123456")
	if err != nil {
		return
	}
	defer fspSession.Close()
	fmt.Printf("fsp server version: %s\n", fspSession.Version())
}

Index

Constants

View Source
const (
	FSPCommandVersion    = 0x10 /* return server's version string.      */
	FSPCommandInfo       = 0x11 /* return server's extended info block  */
	FSPCommandErr        = 0x40 /* error response from server.          */
	FSPCommandGetDir     = 0x41 /* get a directory listing.             */
	FSPCommandGetFile    = 0x42 /* get a file.                          */
	FSPCommandUpload     = 0x43 /* open a file for writing.             */
	FSPCommandInstall    = 0x44 /* close a file opened for writing.     */
	FSPCommandDelFile    = 0x45 /* delete a file.                       */
	FSPCommandDelDir     = 0x46 /* delete a directory.                  */
	FSPCommandGetPro     = 0x47 /* get directory protection.            */
	FSPCommandSetPro     = 0x48 /* set directory protection.            */
	FSPCommandMakeDir    = 0x49 /* create a directory.                  */
	FSPCommandBye        = 0x4A /* finish a session.                    */
	FSPCommandGrabFile   = 0x4B /* atomic get+delete a file.            */
	FSPCommandGrabDone   = 0x4C /* atomic get+delete a file done.       */
	FSPCommandStat       = 0x4D /* get information about file.          */
	FSPCommandRename     = 0x4E /* rename file or directory.            */
	FSPCommandChangePass = 0x4F /* change password                      */
	FSPCommandLimit      = 0x80 /* # > 0x7f for future cntrl blk ext.   */
	FSPCommandTest       = 0x81 /* reserved for testing                 */
)

definition of FSP protocol v2 commands

View Source
const (
	FSPHSzie     = 12
	FSPSpace     = 14708
	FSPMaxPacket = FSPHSzie + FSPSpace
)

FSP packet

View Source
const (
	FSPProBytes  = 1
	FSPDirOwner  = 0x01 // caller owns the directory
	FSPDirDel    = 0x02 // files can be deleted from this dir
	FSPDirAdd    = 0x04 // files can be added to this dir
	FSPDirMkDir  = 0x08 // new subdirectories can be created
	FSPDirGet    = 0x10 // files are NOT readable by non-owners
	FSPDirReadme = 0x20 // directory contain an readme file
	FSPDirList   = 0x40 // directory can be listed
	FSPDirRename = 0x80 // files can be renamed in this directory
)

directory protection bits

View Source
const (
	// VERSION represent fsp lib version.
	VERSION = "1.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error interface {
	error
	Timeout() bool
}

An Error represents a fsp error

type File

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

File fsp file handle

func (*File) Close

func (f *File) Close() (err error)

Close close fsp file

func (*File) Flush

func (f *File) Flush() (err error)

Flush send file buff to server

func (*File) Read

func (f *File) Read(buff []byte, size, count int) (done int, err error)

Read bytes from the file

func (*File) Write

func (f *File) Write(buff []byte) (err error)

Write bytes to file

type Session

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

Session fsp session

func NewSession

func NewSession(serverAddress, password string) (session *Session, err error)

NewSession return a new Session

func NewSessionWithConn

func NewSessionWithConn(conn *net.UDPConn, serverAddress, password string) (session *Session, err error)

NewSessionWithConn return a new Session

func (*Session) CanUpload

func (s *Session) CanUpload(fileName string) (err error)

CanUpload check is user has enough privs for uploading the file

func (*Session) ChangePassword

func (s *Session) ChangePassword(newPassword string) (err error)

ChangePassword change password of fsp server

func (*Session) Close

func (s *Session) Close()

Close close fsp session

func (*Session) DownloadDirectory

func (s *Session) DownloadDirectory(remotePath, savePath string) (err error)

DownloadDirectory download dir from fsp server

func (*Session) DwonloadFile

func (s *Session) DwonloadFile(remotePath, savePath string, retry int) (err error)

DwonloadFile download file from fsp server

func (*Session) GetProtecion

func (s *Session) GetProtecion(directory string) (protection uint8, err error)

GetProtecion get protection byte from directory

func (*Session) Mkdir

func (s *Session) Mkdir(directory string) (err error)

Mkdir create a directory

func (*Session) Readdir

func (s *Session) Readdir(dirpath string) (fi []os.FileInfo, err error)

Readdir reads the contents of the directory

func (*Session) Remove

func (s *Session) Remove(name string) (err error)

Remove delete a file

func (*Session) RemoveAll

func (s *Session) RemoveAll(path string) (err error)

RemoveAll delete a directory

func (*Session) Rename

func (s *Session) Rename(oldpath, newpath string) (err error)

Rename rename file

func (*Session) ShowDir

func (s *Session) ShowDir(dirpath string) (err error)

ShowDir display the files of the dir

func (*Session) Stat

func (s *Session) Stat(name string) (info os.FileInfo, err error)

Stat get information about file/directory

func (*Session) UploadFile

func (s *Session) UploadFile(localFile, remotePath string) (err error)

UploadFile upload file to fsp server

func (*Session) Version

func (s *Session) Version() (version string)

Version Get server version string and setup

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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