receive

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "receive",
	Usage:     "search for peers in your local network and the DHT",
	Aliases:   []string{"r", "get"},
	Action:    Action,
	ArgsUsage: "[WORD-CODE]",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "auto-accept",
			Aliases: []string{"yes", "y"},
			Usage:   "automatically accept the file transfer",
			EnvVars: []string{"PCP_AUTO_ACCEPT"},
		},
	},
	Description: `The receive subcommand starts searching for peers in your local 
network by sending out multicast DNS queries. These queries are
based on the current time and the first word of the given list. It
simultaneously queries the distributed hash table (DHT) with the
exact same parameters.

It is important to note that many networks restrict the use of
multicasting, which prevents mDNS from functioning. Notably,
multicast cannot be used in any sort of cloud, or shared infra-
structure environment. However it works well in most office, home,
or private infrastructure environments.

After it has found a potential peer it starts a password authen-
ticated key exchange (PAKE) with the remaining three words to
proof that the peer is in possession of the password. While this
is happening the tool still searches for other peers as the
currently connected one could fail the authentication procedure.

After the authentication was successful you need to confirm the
file transfer. The confirmation dialog shows the name and size of
the file.

The file will be saved to your current working directory overwriting
any files with the same name. If the transmission fails the file 
will contain the partial written bytes.`,
}

Command contains the receive sub-command configuration.

Functions

func Action

func Action(c *cli.Context) error

Action is the function that is called when running pcp receive.

Types

type Discoverer

type Discoverer interface {
	Discover(chanID int, handler func(info peer.AddrInfo)) error
	Shutdown()
}

type Node

type Node struct {
	*pcpnode.Node
	// contains filtered or unexported fields
}

func InitNode

func InitNode(c *cli.Context, words []string) (*Node, error)

func (*Node) HandlePeer

func (n *Node) HandlePeer(pi peer.AddrInfo)

HandlePeer is called async from the discoverers. It's okay to have long running tasks here.

func (*Node) HandlePushRequest

func (n *Node) HandlePushRequest(pr *p2p.PushRequest) (bool, error)

func (*Node) Shutdown

func (n *Node) Shutdown()

func (*Node) StartDiscovering added in v0.3.0

func (n *Node) StartDiscovering(c *cli.Context)

func (*Node) StopDiscovering

func (n *Node) StopDiscovering()

func (*Node) TransferFinishHandler

func (n *Node) TransferFinishHandler(size int64) chan int64

type PeerState added in v0.4.0

type PeerState uint8
const (
	NotConnected PeerState = iota
	Connecting
	Connected
	FailedConnecting
	FailedAuthentication
)

type TransferHandler

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

func NewTransferHandler

func NewTransferHandler(filename string, done chan int64) (*TransferHandler, error)

func (*TransferHandler) Done added in v0.4.0

func (th *TransferHandler) Done()

func (*TransferHandler) HandleFile added in v0.4.0

func (th *TransferHandler) HandleFile(hdr *tar.Header, src io.Reader)

Jump to

Keyboard shortcuts

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