diff --git a/internal/commander/resolver/resolver.go b/internal/commander/resolver/resolver.go index 956844c..9c5eec7 100644 --- a/internal/commander/resolver/resolver.go +++ b/internal/commander/resolver/resolver.go @@ -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. diff --git a/internal/event/event.go b/internal/event/event.go index 6523d92..9c03630 100644 --- a/internal/event/event.go +++ b/internal/event/event.go @@ -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. @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 } diff --git a/internal/network/net/schema/entry.go b/internal/network/net/schema/entry.go index 040499c..9d8a542 100644 --- a/internal/network/net/schema/entry.go +++ b/internal/network/net/schema/entry.go @@ -2,5 +2,5 @@ package schema type EntryHeader struct { // Entry length. - Length uint64 `json:"length"` + Length uint64 } diff --git a/internal/network/net/schema/hello.go b/internal/network/net/schema/hello.go index fdef2f5..2b70423 100644 --- a/internal/network/net/schema/hello.go +++ b/internal/network/net/schema/hello.go @@ -4,13 +4,13 @@ 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 @@ -18,12 +18,12 @@ type ClientHello struct { 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 } diff --git a/internal/network/net/schema/peer.go b/internal/network/net/schema/peer.go index 292c2fe..2482f39 100644 --- a/internal/network/net/schema/peer.go +++ b/internal/network/net/schema/peer.go @@ -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 diff --git a/internal/network/net/schema/protocol.go b/internal/network/net/schema/protocol.go index ad1efb9..082f6ce 100644 --- a/internal/network/net/schema/protocol.go +++ b/internal/network/net/schema/protocol.go @@ -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: