Documentation ¶
Overview ¶
Package protocol - this package is the application protocol for the application and service.
Index ¶
- Variables
- type CallerType
- type EncryptedMessage
- type Handler
- type Header
- type NodeRegistrationResponse
- type Request
- type RequestMethod
- type Response
- type ResponseStatus
- type RoundTripper
- type Server
- func (s *Server) Handle(method RequestMethod, fn Handler)
- func (s *Server) NodeRegistrationHandler(ctx context.Context, r *Request) Response
- func (s *Server) NodeTrustHandler(ctx context.Context, r *Request) Response
- func (s *Server) Serve(q chan bool, done chan bool)
- func (s *Server) UserRegistrationHandler(ctx context.Context, r *Request) Response
- type SharedSecret
- type Transport
Constants ¶
This section is empty.
Variables ¶
var RequestMethodToString = map[RequestMethod]string{
GetFileMethod: "GetFile",
PostFileMethod: "PostFile",
GetPublicKeyMethod: "GetPublicKey",
PostPublicKeyMethod: "PostPublicKey",
DeleteFileMethod: "DeleteFile",
GetSuccessorMethod: "GetSuccessor",
SetPredecessorMethod: "SetPredecessor",
GetPredecessorMethod: "GetPredecessor",
GetFingerTableMethod: "GetFingerTable",
UserRegistrationMethod: "UserRegistrationMethod",
NodeRegistrationMethod: "NodeRegistrationMethod",
NodeTrustMethod: "NodeTrustMethod",
}
RequestMethodToString - Convert from a Request Method to String
var ( // ValidResponseStatus - Used for verification that a response is right ValidResponseStatus = map[ResponseStatus]bool{ Success: true, Error: true, } )
Functions ¶
This section is empty.
Types ¶
type EncryptedMessage ¶
EncryptedMessage - this will be the "wrapper" to add encryption to the messages. The transport will pack the existing request/response into this encrypted message
func (*EncryptedMessage) Validate ¶
func (em *EncryptedMessage) Validate() error
Validate - Implement validate for the header validation
type Header ¶
type Header struct { Key models.Identifier From models.Identifier FromAddr string Type CallerType PubKey *rsa.PublicKey SignedBy models.Identifier Signature []byte DataLength uint64 ResourceName string Log bool Clock uint64 Secret []byte }
Header - protocol header, used in every message, contains the peerstore version, the key (if applicable), from and to nodes and the length of the data in the data section of the message.
type NodeRegistrationResponse ¶
type NodeRegistrationResponse struct { Signature []byte SignedBy models.Identifier Nodes []models.Node }
type Request ¶
type Request struct { Header Header Method RequestMethod Data []byte }
Request - the standard request, includes a header, method and data. The resource is defined in the header and the data length is defined in the header as well.
type RequestMethod ¶
type RequestMethod uint64
RequestMethod - this is the indication of what request is to be performed.
const ( // GetFileMethod - Get File Method to be used when getting files GetFileMethod RequestMethod = 1 << iota // PostFileMethod - Post File Method to be used when inserting or updating PostFileMethod // DeleteFileMethod - Delete File Method to be used when deleting files DeleteFileMethod // GetSuccessorMethod - Chord Method to get the successor GetSuccessorMethod // SetPredecessorMethod - Chord Method to set the predecessor SetPredecessorMethod // GetPredecessorMethod - Chord Method to get the predecessor GetPredecessorMethod // GetFingerTableMethod - Chord Method to get the finger table GetFingerTableMethod // UserRegistrationMethod - user registration methos UserRegistrationMethod // NodeRegistrationMethod - user registration methos NodeRegistrationMethod // NodeTrustMethod - user registration methos NodeTrustMethod GetPublicKeyMethod PostPublicKeyMethod )
type Response ¶
type Response struct { Header Header Status ResponseStatus Data []byte }
Response - the response structure for any given request
type ResponseStatus ¶
type ResponseStatus int64
ResponseStatus - the type which indicates the response status for a request
const ( // Success - the message request was successful Success ResponseStatus = 1 << iota // Error - the message request was not successful Error )
type RoundTripper ¶
RoundTripper - interface which will perform the request, and return the Response
type Server ¶
type Server struct { PrivateKey *rsa.PrivateKey // contains filtered or unexported fields }
Server - base server type, contains a listener to listen for sockets
func NewServer ¶
func NewServer(key *rsa.PrivateKey, peer models.Node, address, dataPath string, bufferSize, numWorkers uint) (*Server, error)
NewServer - create a new server
func (*Server) Handle ¶
func (s *Server) Handle(method RequestMethod, fn Handler)
Handle - add handlers to the server
func (*Server) NodeRegistrationHandler ¶
NodeRegistrationHandler - this handler handles all node registrations. A node registration consists of the node giving the server it's public key, and the server signing that key, and returning the signed key as well as a list of other nodes with coreseponding public keys that it knows about
func (*Server) NodeTrustHandler ¶
NodeTrustHandler - this handler handles all node trust requests. A node registration consists of the node giving the server it's public key, and the server signing that key, and returning the signed key as well as a list of other nodes with coreseponding public keys that it knows about
func (*Server) Serve ¶
Serve - process to serve requests, for each request that we accept as a connection, we will fork the handling of that connection.
func (*Server) UserRegistrationHandler ¶
UserRegistrationHandler - this handler handles all user registrations. A user registration consists of the user giving the server it's public key, and the server will place that public key in the DHT for future validations
type SharedSecret ¶
type SharedSecret struct {}
type Transport ¶
type Transport struct { Type CallerType // contains filtered or unexported fields }
Transport - a transport structure that will implement RoundTripper transport will also handle all encryption/decryption of the messages
func NewTransport ¶
func NewTransport(proto, addr string, t CallerType, id models.Identifier, peerKey *rsa.PublicKey, selfKey *rsa.PrivateKey) (*Transport, error)
NewTransport - create a new transport structure