Documentation ¶
Index ¶
- Constants
- func CheckFilename(name string) error
- func ChooseCRandomAmongN(c, n int) []int
- func EqualAddr(addr1, addr2 net.UDPAddr) bool
- func FieldCounter(p *GossipPacket) int
- func FlattenKeywords(old []string) string
- func GetAckIdentifier(origin, peer string, id uint32) string
- func GetRand(n int) int
- func GetRealRand(n int) int
- func IntInSlice(a int, list []int) bool
- func ParsePeers(peerList *string) *[]net.UDPAddr
- func ProtobufGossip(msg *GossipPacket) []byte
- func ProtobufMessage(msg *Message) []byte
- func RemoveAddrFromPeers(peers []net.UDPAddr, addr net.UDPAddr) []net.UDPAddr
- func SameSearch(search SearchStatus, req SearchRequest) bool
- func SplitKeywords(kw string) []string
- func SyncMapCount(sm *sync.Map) uint32
- func TestMessageType(p *GossipPacket) bool
- type AckValues
- type BlockPublish
- type DataReply
- type DataRequest
- type FileChunk
- type FileRequestStatus
- type FileStatusList
- type FileStruct
- type GossipPacket
- type List
- type Message
- type Node
- type PeerStatus
- type PrivateMessage
- type Queue
- type RumorMessage
- type SearchFile
- type SearchReply
- type SearchRequest
- type SearchResult
- type SearchStatus
- type ShaHash
- type SimpleMessage
- type StatusPacket
- type SyncNewMessages
- type TLCAck
- type TLCMessage
- type TxPublish
Constants ¶
const ( // SimpleModeStr : string containing the name for gossiper simple mode SimpleModeStr string = "simple" // RumorModeStr : string containing the name for gossiper rumor mode RumorModeStr string = "rumor" // TimeoutValue : timeout value in seconds TimeoutValue int = 10 // AntiEntropyDefault : default value in seconds for anti entropy AntiEntropyDefault int = 10 // RTimerDefault is the defaut value for rtimer RTimerDefault int = 0 // LocalhostAddr : "127.0.0.1" LocalhostAddr string = "127.0.0.1" // DefaultUIPort : 8080 DefaultUIPort string = "8080" // DefaultGUIPort : 8080 DefaultGUIPort string = "8080" // PrivateMessageID is the ID for private messages PrivateMessageID uint32 = 0 // DefaultHopLimit default hop limit for private messages DefaultHopLimit uint32 = 10 SharedFolderName string = "_SharedFiles" // DownloadsFolderName path to the gossiper's downloads folder DownloadsFolderName string = "_Downloads" // Filemode is file mode for the shared and download folders Filemode os.FileMode = 0666 // ChunkSize size of a file chunk to send (8KB) ChunkSize int = 8192 // 8 KB // BufferSize : read buffer size in bytes BufferSize int = ChunkSize + 2048 // ShaSize length of a sha hash in bytes ShaSize int = sha256.Size // FileTimout timeout value for file requests in seconds FileTimout int = 5 // DefaultSearchBudget default search budget DefaultSearchBudget uint64 = 2 // NoSearchBudget default search budget if not given as argument NoSearchBudget int = 0 // MaxSearchBudget max search budget MaxSearchBudget uint64 = 32 // DefaultGossiperName default gossiper name DefaultGossiperName string = "Gossiper" // DefaultDuplicateSearchTime default time in which the same search request // is considered as duplicate DefaultDuplicateSearchTime time.Duration = 500 * time.Millisecond // SearchPeriod search requests should be sent periodically with this // period SearchPeriod time.Duration = time.Second // MatchThreshold threshold of search matchs MatchThreshold int = 2 // DefaultPeerNumber default N DefaultPeerNumber int = 3 // StubbornTimeoutDefault in seconds StubbornTimeoutDefault int = 5 // UnconfirmedInt value for TLCMessage confirmed UnconfirmedInt int = -1 // OwnTLCBufferSize OwnTLCBufferSize OwnTLCBufferSize int = 50 // OutsideTLCBufferSize OutsideTLCBufferSize OutsideTLCBufferSize int = 200 // SecurityLimit for iterating on blocks and hashs SecurityLimit int = 100 )
Variables ¶
This section is empty.
Functions ¶
func CheckFilename ¶
CheckFilename check if the filename is correct and return an error if not
func ChooseCRandomAmongN ¶
ChooseCRandomAmongN select c distinct random number between 0 and n
func EqualAddr ¶
EqualAddr : compares the given UDPAddr, returns false if they are different and true otherwise
func FieldCounter ¶
func FieldCounter(p *GossipPacket) int
FieldCounter count the number of fields in a GossipPacket
func FlattenKeywords ¶
FlattenKeywords flatten list of string to single string
func GetAckIdentifier ¶
GetAckIdentifier get the unique message identifier associated with the given parameters. origin: Origin of the acked message peer: peer with whom the gossip is exchanged id: Id of the gossip
func GetRealRand ¶
GetRealRand : returns a really random number generated with crypto package
func IntInSlice ¶
IntInSlice return true if a is in slice list
func ProtobufGossip ¶
func ProtobufGossip(msg *GossipPacket) []byte
ProtobufGossip : encapsulates a gossip message using protobuf
func ProtobufMessage ¶
ProtobufMessage : encapsulate a client message using protobuf
func RemoveAddrFromPeers ¶
RemoveAddrFromPeers : remove the given address from the array of addresses
func SameSearch ¶
func SameSearch(search SearchStatus, req SearchRequest) bool
SameSearch compare a search status with a search request, return true if the search is the same
func SplitKeywords ¶
SplitKeywords given a string, split the keywords separated by comas and returns a list of keyword strings
func SyncMapCount ¶
SyncMapCount : count the number of elements in a sync map
func TestMessageType ¶
func TestMessageType(p *GossipPacket) bool
TestMessageType : test if the packet only contains a message type and prints an error and returns false if it is not the case
Types ¶
type AckValues ¶
type AckValues struct { Channel *chan bool InitialMessage GossipPacket }
AckValues : values pointed by an AckIdentifier
type BlockPublish ¶
BlockPublish block publish structure
func (*BlockPublish) Hash ¶
func (b *BlockPublish) Hash() (out [32]byte)
Hash function of BlockPublish
type DataReply ¶
type DataReply struct { Origin string Destination string HopLimit uint32 HashValue []byte Data []byte }
DataReply data reply packets
type DataRequest ¶
DataRequest data request packets
type FileChunk ¶
type FileChunk struct { File *FileStruct Number int Hash ShaHash Data []byte }
FileChunk one chunk of data of a file
type FileRequestStatus ¶
type FileRequestStatus struct { File *FileStruct Destination [][]string MetafileOK bool PendingChunks []ShaHash ChunkCount int Ack chan bool }
FileRequestStatus status for a file request
type FileStatusList ¶
type FileStatusList struct { sync.Mutex List []FileRequestStatus }
FileStatusList list of file request statuses
type FileStruct ¶
type FileStruct struct { Name string MetafileHash ShaHash Size int64 Metafile []byte NChunks int Chunks map[ShaHash]*FileChunk Done bool }
FileStruct file structure containing file's metadata stored on the gossiper
type GossipPacket ¶
type GossipPacket struct { Simple *SimpleMessage Rumor *RumorMessage Status *StatusPacket Private *PrivateMessage DataRequest *DataRequest DataReply *DataReply SearchRequest *SearchRequest SearchReply *SearchReply TLCMessage *TLCMessage Ack *TLCAck }
GossipPacket : default gossip packet used by the Peerster
func UnprotobufGossip ¶
func UnprotobufGossip(packet []byte) (*GossipPacket, bool)
UnprotobufGossip : decapsulate a gossip message using protobuf
type Message ¶
type Message struct { Text string Destination *string File *string Request *[]byte Budget *uint64 Keywords *[]string }
Message : simple message type that client send to gossiper
func UnprotobufMessage ¶
UnprotobufMessage : decapsulate a gossip message using protobuf
type Node ¶
type Node struct { Block BlockPublish Hash ShaHash Prev *Node Next *Node }
Node of double linked list
type PeerStatus ¶
PeerStatus : a status is useful to ask a peer some packets
type PrivateMessage ¶
type PrivateMessage struct { Origin string ID uint32 Text string Destination string HopLimit uint32 }
PrivateMessage : private message structure
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a basic FIFO queue based on a circular list that resizes as needed.
type RumorMessage ¶
RumorMessage : Rumor message containing the original sender's name, a sequence number and the content. The message should be uniquely identified by the combination of Origin and ID
type SearchFile ¶
type SearchFile struct { Name string MetafileHash ShaHash Chunks map[uint64]map[string]bool NChunks uint64 Complete bool }
SearchFile search file structure
type SearchReply ¶
type SearchReply struct { Origin string Destination string HopLimit uint32 Results []*SearchResult }
SearchReply search reply packet
type SearchRequest ¶
SearchRequest search request packet
type SearchResult ¶
type SearchResult struct { FileName string MetafileHash []byte ChunkMap []uint64 ChunkCount uint64 }
SearchResult search result included in search reply
type SearchStatus ¶
SearchStatus search status kept at the gossiper
type SimpleMessage ¶
SimpleMessage : a simple message structure containing the original sender's name, the relay peer address, and the content of the message
type StatusPacket ¶
type StatusPacket struct {
Want []PeerStatus
}
StatusPacket : a StatusPacket is a packet containing a list of PeerStatus that are wanted by the sender
type SyncNewMessages ¶
type SyncNewMessages struct { sync.Mutex Messages []RumorMessage }
SyncNewMessages : sync slice of rumor messages
type TLCMessage ¶
type TLCMessage struct { Origin string ID uint32 Confirmed int TxBlock BlockPublish VectorClock *StatusPacket Fitness float32 }
TLCMessage structure