peer

package
v0.0.0-...-d617ca5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//PeerIDLen is length of peer id
	PeerIDLen = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager manage peers of the task

func NewManager

func NewManager(torrent *meta.Torrent, path string, memc chan int64) *Manager

NewManager return a Manager instance

func (*Manager) AddAddrPeer

func (m *Manager) AddAddrPeer(addrs []string)

AddAddrPeer add peer from addr

func (*Manager) AddPeer

func (m *Manager) AddPeer(ctx context.Context, conn net.Conn, extension [reserved]byte)

AddPeer add peer to peers

func (*Manager) Close

func (m *Manager) Close() error

Close close then manager

func (*Manager) GetStatus

func (m *Manager) GetStatus() *Status

GetStatus return downalod status

func (*Manager) Run

func (m *Manager) Run() (err error)

Run start peers's work

func (*Manager) Save

func (m *Manager) Save()

Save save data from memory to disk

type Server

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

Server is a local server for other peer

func NewServer

func NewServer(addr string) (*Server, error)

NewServer create a peer server

func NewServerWithIdentifier

func NewServerWithIdentifier(addr, ident, version string) (*Server, error)

NewServerWithIdentifier create a peer server with identifier display in peer id

func (*Server) Accept

func (s *Server) Accept() (info meta.Hash, conn net.Conn, extension [reserved]byte, err error)

Accept accept a vaild handshake message

func (*Server) Addr

func (s *Server) Addr() string

Addr return ther server addr

func (*Server) Close

func (s *Server) Close() error

Close close the Server

func (*Server) ID

func (s *Server) ID() [PeerIDLen]byte

ID return the server id

func (*Server) Listen

func (s *Server) Listen() (err error)

Listen start listen at addr and wait other peer connect

type Status

type Status struct {
	PeerNum int
	Status  *tracker.DownloadStatus
}

Status is downlod stautus

Jump to

Keyboard shortcuts

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