Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions internal/commander/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import (
)

type DomainPeerMetadata struct {
schema.PeerMetadata `json:",inline" yaml:",inline"`
Domain string `json:"domain" yaml:"domain"`
schema.PeerMetadata `yaml:",inline"`
Domain string `yaml:"domain"`
}

type EntriesList struct {
Entries []DomainPeerMetadata `json:"entries" yaml:"entries"`
Entries []DomainPeerMetadata `yaml:"entries"`
}

type DomainMetadata struct {
// Domain is the domain name of the peer.
Domain string `json:"domain" yaml:"domain"`
Domain string `yaml:"domain"`

// PeerMetadata contains the metadata of the peer.
schema.PeerMetadata `json:",inline" yaml:",inline"`
schema.PeerMetadata `yaml:",inline"`
}

// Resolves a domain to a pid, host, and port.
Expand Down
74 changes: 38 additions & 36 deletions internal/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,33 @@ type InitConnectionEvent struct {
// IPv4 of the destination router.
// In the future it might be changed to uint64
// to support IPv6.
Host uint32 `json:"host"`
Host uint32

// Port of the destination router.
Port uint16 `json:"port"`
Port uint16

// PeerID of the destination router.
PID schema.PeerID `json:"peer_id"`
PID schema.PeerID
}

type PeerConnectedEvent struct {
// ID of the peer that is connected.
PID schema.PeerID `json:"peer_id"`
PID schema.PeerID
}

// Request event.
type IsPeerConnectedEvent struct {
// PeerID of the requested peer.
PID schema.PeerID `json:"peer_id"`
PID schema.PeerID
}

// Response event.
type PeerStatusEvent struct {
// PeerID of the requested peer.
PID schema.PeerID `json:"peer_id"`
PID schema.PeerID

// Is the peer connected.
Connected bool `json:"connected"`
Connected bool
}

// Request event.
Expand All @@ -115,39 +115,39 @@ type GetConnectedPeersEvent struct {
// Response event.
type ConnectedPeersEvent struct {
// List of connected peers.
Peers []schema.PeerID `json:"peers"`
Peers []schema.PeerID
}

type GetPeerEntryEvent struct {
// PeerID of the destination peer.
PID schema.PeerID `json:"peer_id"`
PID schema.PeerID

// Entry to send.
EntryMeta entry.EntryMeta `json:"entry"`
EntryMeta entry.EntryMeta
}

type PeerEntryEvent struct {
// PeerID of the source peer.
PID schema.PeerID `json:"peer_id"`
PID schema.PeerID

// Entry received.
Entry entry.Entry `json:"entry"`
Entry entry.Entry

// Error if entry retrieval failed.
Error error `json:"error,omitempty"` // Optional error if entry retrieval failed
Error error
}

type GetLocalEntryEvent struct {
// Entry to get from storage.
EntryMeta entry.EntryMeta `json:"entry"`
EntryMeta entry.EntryMeta
}

type LocalEntryEvent struct {
// Entry received from storage.
Entry entry.Entry `json:"entry"`
Entry entry.Entry

// Error if entry retrieval failed.
Error error `json:"error,omitempty"` // Optional error if entry retrieval failed
Error error
}

type ListLocalFilesEvent struct {
Expand All @@ -156,42 +156,42 @@ type ListLocalFilesEvent struct {

type LocalFilesEvent struct {
// StorageTree representing the local files.
StorageTree models.StorageTree `json:"storage_tree"`
StorageTree models.StorageTree

// Error if files retrieval failed.
Error error `json:"error,omitempty"` // Optional error if files retrieval failed
Error error
}

type AddFileEvent struct {
// Path where the file should be added.
Path string `json:"path"`
Path string

// Filename of the file to be added.
Filename string `json:"filename"`
Filename string

// RawFile is the content of the file to be added.
RawFile []byte `json:"raw_file"`
RawFile []byte
}

type AddFileStatusEvent struct {
// Status of the file addition.
Error error `json:"error,omitempty"` // Optional error if file addition failed
Error error
}

type CommanderGetEntryEvent struct {
// Entry to get from storage.
EntryMeta entry.EntryMeta `json:"entry"`
EntryMeta entry.EntryMeta

// Domain of the entry.
Domain string `json:"domain"`
Domain string
}

type CommanderEntryEvent struct {
// Entry received from the commander.
Entry entry.Entry `json:"entry"`
Entry entry.Entry

// Error if entry retrieval failed.
Error error `json:"error,omitempty"` // Optional error if entry retrieval failed
Error error
}

type CommanderGetDomainEvent struct {
Expand All @@ -200,10 +200,10 @@ type CommanderGetDomainEvent struct {

type CommanderDomainEvent struct {
// Domain of the commander.
Domain string `json:"domain"`
Domain string

// Error if domain retrieval failed.
Error error `json:"error,omitempty"` // Optional error if domain retrieval failed
Error error
}

type CommanderGetNeighborsEvent struct {
Expand All @@ -212,10 +212,10 @@ type CommanderGetNeighborsEvent struct {

type CommanderNeighborsEvent struct {
// List of neighbors.
Neighbors []string `json:"neighbors"`
Neighbors []string

// Error if neighbors retrieval failed.
Error error `json:"error,omitempty"` // Optional error if neighbors retrieval failed
Error error
}

type CommanderListLocalFilesEvent struct {
Expand All @@ -224,22 +224,24 @@ type CommanderListLocalFilesEvent struct {

type CommanderLocalFilesEvent struct {
// StorageTree representing the local files.
StorageTree models.StorageTree `json:"storage_tree"`
StorageTree models.StorageTree

// Error if files retrieval failed.
Error error `json:"error,omitempty"` // Optional error if files retrieval failed
Error error
}

type CommanderAddFileEvent struct {
// Path where the file should be added.
Path string `json:"path"`
Path string

// Filename of the file to be added.
Filename string `json:"filename"`
Filename string

// RawFile is the content of the file to be added.
RawFile []byte `json:"raw_file"`
RawFile []byte
}

type CommanderAddStatusEvent struct {
// Status of the file addition.
Error error `json:"error,omitempty"` // Optional error if file addition failed
Error error
}
2 changes: 1 addition & 1 deletion internal/network/net/schema/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package schema

type EntryHeader struct {
// Entry length.
Length uint64 `json:"length"`
Length uint64
}
10 changes: 5 additions & 5 deletions internal/network/net/schema/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ type ClientHello struct {
// IPv4 of the client.
// In the future it might be changed to uint64
// to support IPv6.
Host uint32 `json:"host"`
Host uint32

// Port of the client.
Port uint16 `json:"port"`
Port uint16

// Passkey for the server to be identifiable by the client.
Key [16]byte `json:"key"`
Key [16]byte

// Pad.
_ uint16
}

type ServerHello struct {
// Passkey, issued by client, to identify the server.
Key [16]byte `json:"key"`
Key [16]byte
}

type ClientHelloAck struct {
// Indicates either the client is connected or not.
// Note: perhaps this should be changed to more
// reliable message.
Connected bool `json:"connected"`
Connected bool
}
6 changes: 3 additions & 3 deletions internal/network/net/schema/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
// Metadata of a peer in the network.
type PeerMetadata struct {
// PeerID is the unique identifier for the peer.
PID PeerID `json:"pid" yaml:"pid"`
PID PeerID `yaml:"pid"`

// Host is the host address of the peer.
Host uint32 `json:"host" yaml:"host"`
Host uint32 `yaml:"host"`

// Port is the port number of the peer.
Port uint16 `json:"port" yaml:"port"`
Port uint16 `yaml:"port"`
}

type PeerID uint32
Expand Down
16 changes: 8 additions & 8 deletions internal/network/net/schema/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ const (

// NOTE: Should be aligned manually with the protocol
type Header struct {
Magic uint32 `json:"magic"`
Version uint16 `json:"version"`
Magic uint32
Version uint16
_ uint16
PayloadLen uint32 `json:"payload_len"`
PayloadLen uint32
}

// NOTE: Should be aligned manually with the protocol
type Preamble struct {
PeerID uint32 `json:"peer_id"`
TaskID uint32 `json:"task_id"`
PeerID uint32
TaskID uint32
}

// NOTE: Should be aligned manually with the protocol
type Frame struct {
Header Header `json:"header"`
Preamble Preamble `json:"preamble"`
Payload []byte `json:"payload"`
Header Header
Preamble Preamble
Payload []byte
}

// Static assertions:
Expand Down