Documentation ¶
Index ¶
- type RecvConnection
- type SenderConnection
- type Server
- func (s *Server) ContinueUpload(ack *messages.DataPacketAck, conn *net.UDPConn, returnAddr *net.UDPAddr) error
- func (s *Server) DiscoverHosts(hash *common.Sha1Hash, chunks []uint16) []messages.DiscoverHostResponse
- func (s *Server) HandleMessage(message []byte, conn *net.UDPConn, returnAddr *net.UDPAddr) error
- func (s *Server) ListFilesOnHost(ipv4 [4]byte, port uint16, hash *common.Sha1Hash) (*messages.ListFilesResponse, error)
- func (s *Server) LocalIP() *net.IP
- func (s *Server) Port() int
- func (s *Server) RespondToDiscoverHosts(req *messages.DiscoverHostRequest, returnAddr *net.UDPAddr) error
- func (s *Server) RespondToListFilesOnHost(req *messages.ListFilesRequest, conn *net.UDPConn, returnAddr *net.UDPAddr) error
- func (s *Server) StartDownload(hash *common.Sha1Hash) error
- func (s *Server) StartUpload(msg *messages.OpenConnectionRequest, conn *net.UDPConn, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RecvConnection ¶
type RecvConnection struct {
// contains filtered or unexported fields
}
func (*RecvConnection) Ack ¶
func (r *RecvConnection) Ack(offset uint32)
func (*RecvConnection) Read ¶
func (r *RecvConnection) Read() (*messages.DataPacket, bool)
type SenderConnection ¶
type SenderConnection struct {
// contains filtered or unexported fields
}
func NewSenderConnection ¶
func NewSenderConnection(reader *common.ChunkReader, windowCap uint16, conn *net.UDPConn, addr *net.UDPAddr, ) *SenderConnection
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server dispatches and responds to flu messages. It contains enough internal state to map an incoming UDP message to a previous outgoing message, thereby providing a request/response paradigm when needed. Every request/response is tagged with a monotonically-increasing requestID so many conversations can occur concurrently. All incoming UDP messages should be sent to Server for handling.
func (*Server) ContinueUpload ¶
func (*Server) DiscoverHosts ¶
func (s *Server) DiscoverHosts( hash *common.Sha1Hash, chunks []uint16, ) []messages.DiscoverHostResponse
DiscoverHosts broadcasts a DiscoverHostRequest on the local network, collects responses for a few seconds, and returns the collected results. Both arguments are optional and serve as filters.
func (*Server) HandleMessage ¶
HandleMessage does exactly what it says. It expects parameters to be passed by value because it is assumed it will be run concurrently.
func (*Server) ListFilesOnHost ¶
func (s *Server) ListFilesOnHost( ipv4 [4]byte, port uint16, hash *common.Sha1Hash, ) (*messages.ListFilesResponse, error)
ListFilesOnHost sends a request for a list of files from a remote host and returns the response. The request times out if not fulfilled in a few seconds
func (*Server) LocalIP ¶
LocalIP returns the IPV4 address of the running process (if available). This is not the loopback address (192.168.0.1; 'localhost'), but the address assigned to this host by the LAN's router.
func (*Server) RespondToDiscoverHosts ¶
func (*Server) RespondToListFilesOnHost ¶
func (*Server) StartDownload ¶
StartDownload creates a progressfile for the specified file, adds it to the catalogue, and begins the download. A name for the file is chosen arbitrarily from one of the hosts who have that file.