clientproperties

package
v0.0.0-...-75d0260 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncDownloader

func AsyncDownloader(wg *sync.WaitGroup, client *http.Client, start int64, end int, i int, size int, url string, f *os.File) error

AsyncDownloader downloader function

func CheckFileExistence

func CheckFileExistence(request FileRequest, directoryFiles *ClientFiles) bool

CheckFileExistence checking existence of file to send it to some peer

func DisplayNumRecentMessages

func DisplayNumRecentMessages(mymessages *MyReceivedMessages, recentCount int) string

DisplayNumRecentMessages To display Num recent messages

func DisplayRecentUnseenMessages

func DisplayRecentUnseenMessages(mymessages *MyReceivedMessages) string

DisplayRecentUnseenMessages To display the most recent messages which haven't been seen yet

func Download

func Download(args string)

Download ..

func DummyAsync

func DummyAsync(wg *sync.WaitGroup, client *http.Client, start int64, end int, i int, size int, url string, f *os.File) error

DummyAsync simulates Async

func FileSenderCredentials

func FileSenderCredentials(broadcast bool) (string, string)

FileSenderCredentials getting the details for sending file request

func GetFileParts

func GetFileParts(completefilename string, partSize uint64, filesize int64, i uint64, fileContents []byte,
	allFileParts []FilePartInfo, wgSplit *sync.WaitGroup, totalParts int)

GetFileParts - goroutine to get all the parts of file to be sent over the network

func GetRequestedFile

func GetRequestedFile(activeClient *ClientListen, myname string, fileSenderName string, fileName string) string

GetRequestedFile To get file from a peer

func ListenOnSelfPort

func ListenOnSelfPort(ln net.Listener, myname string, activeClient *ClientListen, myfiles map[string]MyReceivedFiles,
	mymessages *MyReceivedMessages, directoryFiles *ClientFiles)

ListenOnSelfPort listens for clients on network

func MessageReceiverCredentials

func MessageReceiverCredentials() (string, string)

MessageReceiverCredentials for receiving message credientials

func RequestMessage

func RequestMessage(activeClient *ClientListen, name string, messageReceiverName string,
	message string) string

RequestMessage takes message from client and dials to receiver

func RequestSomeFile

func RequestSomeFile(activeClient *ClientListen, myname string, fileName string) string

RequestSomeFile To broadcast the file request to everyone on network

func SendFileParts

func SendFileParts(newfilerequest FileRequest, allfileparts []FilePartInfo,
	activeClient *ClientListen, myname string) int

SendFileParts send various file parts to peers

func SendFileRequestToPeer

func SendFileRequestToPeer(connection net.Conn, fileRequest FileRequest, requestType string)

SendFileRequestToPeer To send the request to corresponding peer

func SendPart

func SendPart(names string, activeClient *ClientListen, newfilerequest FileRequest,
	countSent int, allfileparts []FilePartInfo, wgSplit *sync.WaitGroup)

SendPart - To send each file part concurrently

func SendingToServer

func SendingToServer(name []byte, query []byte, conn net.Conn,
	queryType string, listenPort []byte)

SendingToServer - to send queries to server

Types

type BaseRequest

type BaseRequest struct {
	RequestType    string       // type of request
	FileRequest                 // Information about File requseter if its a file request
	FilePartInfo   FilePartInfo // Information about file parts if its a file request
	MessageRequest              // Details of message is its a message request
}

BaseRequest : A base request which is used as a generic request for all types of P2P queries

type Client

type Client struct {
	Address          string
	Name             string
	ConnectionServer net.Conn
}

Client - Struct to store details of specific client

type ClientFiles

type ClientFiles struct {
	FilesInDir []string
}

ClientFiles stores the files in the "files" directory of client

type ClientJob

type ClientJob struct {
	Name             string
	Query            string
	Conn             net.Conn
	ClientListenPort string
}

ClientJob : Stores the names, jobs, query and connection

type ClientListen

type ClientListen struct {
	List           []string          // names of all clients
	PeerIP         map[string]string // IP to name mapping of all clients
	PeerListenPort map[string]string //Port at which all those clients are listening for P2P requests
}

ClientListen Store - all client names,

IP to name mapping of all clients
Port at which all those clients are listening for P2P requests

type ClientQuery

type ClientQuery struct {
	Name             []byte
	Query            []byte
	ClientListenPort []byte
}

ClientQuery : To store name and query of a client

type FilePartContents

type FilePartContents struct {
	Contents []byte
}

FilePartContents Contents of a part of file

type FilePartInfo

type FilePartInfo struct {
	FileName         string
	TotalParts       int
	PartName         string
	PartNumber       int
	FilePartContents []byte
}

FilePartInfo Complete Information regarding the file to share

func GetSplitFile

func GetSplitFile(filename string, numberOfActiveClient int) []FilePartInfo

GetSplitFile fuction to return the splitted parts

type FileRequest

type FileRequest struct {
	Query         string
	MyAddress     string
	MyName        string
	RequestedFile string
}

FileRequest stores the queries and information about requester

type MessageRequest

type MessageRequest struct {
	SenderQuery   string
	SenderAddress string
	SenderName    string
	Message       string
}

MessageRequest Stores the information about requester, who is sending the message (for the receiver to reply back)

type MyPeers

type MyPeers struct {
	Conn     net.Conn
	PeerName string
}

MyPeers : List of peers to which a clinet dials

type MyReceivedFiles

type MyReceivedFiles struct {
	PartsReceived int
	MyFileName    string             // name of file
	MyFile        []FilePartContents // Contents of the file
	FilePartInfo  FilePartInfo       // Information of various file parts
}

MyReceivedFiles : To store the information of files received by client

type MyReceivedMessages

type MyReceivedMessages struct {
	Counter    int              // The counter from which client has to start reading the messages
	MyMessages []MessageRequest // slice of structs of type MessageRequest to store all message requests
}

MyReceivedMessages To store the information of the messages receievd

type WriteCounter

type WriteCounter struct {
	Total uint64
}

WriteCounter - Count of writer

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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