Help us shape the future of Go! Take the 2026 Go Developer Survey

cpf

package module
v0.1.1 Latest Latest
Warning

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

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

README

简介

cpf 简单的文件传输协议

支持DEL、PUT上传文件 支持GET下载文件,GET支持多目录

例子

func main() {
	server := cpf.NewServer(nil, nil)
	server.ListenAndServe("localhost:8200")
}

客户端测试

可以在终端上使用telnet测试

telnet localhost 8200
AUTH arg
+OK auth success

DEL 123.txt
+OK success

PUT 123.txt auto
+OK filesize

GET 123.txt offset
+OK filesize

QUIT
+OK good bye

一共5个指令,其中 执行 PUT或GET指令后,程序 进入 数据传输模式。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufPool = sync.Pool{
	New: func() interface{} {
		b := make([]byte, maxBufSize)
		return &b
	},
}

BufPool buf pool

View Source
var ErrNotPathID = errors.New("cpf: not pathID")

ErrNotPathID 是QueryGetPath的特指

Functions

This section is empty.

Types

type Client

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

Client is a cpf connect

func Dial

func Dial(address string) (*Client, error)

Dial new Client and Connect

func (*Client) Close

func (c *Client) Close()

Close thar close the conn

func (*Client) Get

func (c *Client) Get(name string, wser io.WriteSeeker, fn func(int) bool) int64

Get 下载文件 fn Progress callback

func (*Client) Put

func (c *Client) Put(name string, rser io.ReadSeeker, fn func(int) bool) int64

Put 上传文件 fn Progress callback

type LFile

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

LFile is a

func OpenFile

func OpenFile(name string, flag int) (*LFile, error)

OpenFile f

func (*LFile) Close

func (f *LFile) Close() error

Close f

func (*LFile) Read

func (f *LFile) Read(p []byte) (n int, err error)

func (*LFile) Seek

func (f *LFile) Seek(offset int64, whence int) (int64, error)

Seek go

func (*LFile) Write

func (f *LFile) Write(p []byte) (n int, err error)

type Server

type Server struct {
	// 欢迎 语句
	Welcome string

	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	// contains filtered or unexported fields
}

Server is a cpf server

func NewServer

func NewServer(cfg configer, log logger) *Server

NewServer create a server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe the addr

func (*Server) SetAuthFunc

func (s *Server) SetAuthFunc(fn func(string) bool)

SetAuthFunc 设置 验证接口, 不设置则为 不启用 验证

func (*Server) SetFileGos

func (s *Server) SetFileGos(count int)

SetFileGos 设置 操作 文件io 的 并发数

Jump to

Keyboard shortcuts

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