cli

package
v0.0.0-...-b8f7ae2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChimRequest

type ChimRequest struct {
	// if provided, only hosts with info on this file will respond.
	Sha1Hash *common.Sha1Hash
}

ChimRequest is a host-discovery message (since chimneys are portals to the floo network in Harry Potter). All hosts are expected to respond with their available info. The details of the ChimRequest indicate just how detailed we want the response to be.

type ChimResponse

type ChimResponse struct {
	HostIP   [4]byte
	HostPort uint16
	Chunks   []uint16
}

ChimResponse lists the available hosts on the network. If a sha1Hash was provided, hosts will include the chunks of that file that they have available.

func (*ChimResponse) Sprintf

func (c *ChimResponse) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a ChimResponse

type ChimResponseList

type ChimResponseList struct {
	Responses []ChimResponse
}

ChimResponseList is a list of ChimResponses

func (*ChimResponseList) Sprintf

func (c *ChimResponseList) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a ChimResponseList

type CleanRequest

type CleanRequest struct{}

CleanRequest is just a signal to the daemon. It contains no specific information

type CleanResponse

type CleanResponse struct {
	Items []CleanResponseItem
}

CleanResponse contains basic information about files that had to be removed

func (*CleanResponse) Sprintf

func (r *CleanResponse) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a CleanResponse

type CleanResponseItem

type CleanResponseItem struct {
	FilePath        string
	IndexedSha1Hash [20]byte
	CurrentSha1Hash [20]byte // If null, file is missing. If different, file is corrupted.
	ActionTaken     string
}

CleanResponseItem contains the FilePath and Sha1Hash information about an indexed file

func (*CleanResponseItem) Sprintf

func (r *CleanResponseItem) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a CleanResponseItem

type Client

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

Client is the entrypoint for code that runs on the CLI process. The user types commands in here and they get executed by the CLI methods on the daemon process that hosts the CLI methods

func NewClient

func NewClient(addr string) *Client

NewClient returns a new client instance

func (*Client) Run

func (c *Client) Run(cmdArgs []string)

Run is the entry point for the CLI

type GetRequest

type GetRequest struct {
	Sha1Hash *common.Sha1Hash // sha1 hash of the file being downloaded
}

GetRequest contains the information necessary to initiate a flu transfer to get a file

type GetResponse

type GetResponse struct{}

GetResponse is an empty struct

func (*GetResponse) Sprintf

func (res *GetResponse) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a GetResponse

type ListItem

type ListItem struct {
	FilePath         string
	SizeInBytes      int64
	Sha1Hash         [20]byte
	ChunkCount       int
	ChunkSizeInBytes int // ChunkCount * ChunkSizeInBytes == SizeInBytes
	// The number of chunks of the file that are downloaded and available for sharing
	ChunksDownloaded int
}

ListItem contains basic information about the file that has been shared.

func (*ListItem) Sprintf

func (li *ListItem) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a ListItem

type ListRequest

type ListRequest struct {
	IP       net.IP
	Sha1Hash *common.Sha1Hash
}

ListRequest contains the information necessary for the daemon to find, hash, index and List the file pointed to by FilePath.

type ListResponse

type ListResponse struct {
	Items []ListItem
}

ListResponse is a slice of ListItems, each of which details a file that is shared by the daemon. The contents of files in the ListResponse are guaranteed unique. Not all files that have been listed have been completely downloaded.

func (*ListResponse) Sprintf

func (lr *ListResponse) Sprintf() string

Sprintf returns a pretty-printed, user-facing string representation of a ListResponse

type Methods

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

Methods is the 'public' (CLI-facing) interface of the client daemon process. These methods are imported and used directly by github.com/flu-network/cli over unix domain sockets, exposed by main.go

func NewMethods

func NewMethods(cat *catalogue.Cat, fluServer *flu.Server) *Methods

NewMethods returns a NewMethods instance. cat is expected to be initialized by the caller.

func (*Methods) Chims

func (m *Methods) Chims(req *ChimRequest, resp *ChimResponseList) error

Chims lists available hosts on the network. If a sha1 is provided, only hosts that have at least some of that file will respond, and their responses will be scoped to that one file.

func (*Methods) Clean

func (m *Methods) Clean(req *CleanRequest, resp *CleanResponse) error

Clean checks if each file in the index can be safely shared, removes those that can't from the index and returns errors for those removed files

func (*Methods) Get

func (m *Methods) Get(req *GetRequest, res *GetResponse) error

Get initiates a flu transfer for the specified file

func (*Methods) List

func (m *Methods) List(req *ListRequest, resp *ListResponse) error

List lists the files that have been indexed by the daemon. Not all indexed files have been downloaded in their entirety.

func (*Methods) Share

func (m *Methods) Share(req *ShareRequest, resp *ListItem) error

Share attempts to add the specified file to flu's index, making it available to anyone on your local area network. If an identical file has already been added (even if has a different name), flu will refuse to index it twice and return an error telling you which file it was. Sharing a file assumes that the file has been downloaded in its entirety, and that its contents will not change... ever.

type Printable

type Printable interface {
	Sprintf() string
}

Printable is anything that returns a pretty-printed string to show an end user

type ShareRequest

type ShareRequest struct {
	Filepath string
}

ShareRequest contains the information necessary for the daemon to find, hash, index and share the file pointed to by FilePath.

Jump to

Keyboard shortcuts

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