Documentation
¶
Index ¶
- Variables
- func DeserializeFrame(r io.Reader, f *IncomingFrame) error
- func DeserializeResponseMessage(r io.Reader, res *ResponseMessage) error
- func MarshalFrame(f *OutgoingFrame) ([]byte, error)
- func MarshalRequestMessage(m *OutgoingRequestMessage) ([]byte, error)
- func SerializeBufferIntoFrame(w io.Writer, buf *bytes.Buffer, sessionID []byte) error
- func SerializeFrame(w io.Writer, f *OutgoingFrame) error
- func SerializeIntoFrame(w io.Writer, r io.Reader, sessionID []byte) error
- func SerializeRequestMessage(w io.Writer, m *OutgoingRequestMessage) error
- func UnmarshalCloseMessage(p []byte, res *CloseMessage) error
- func UnmarshalFrame(p []byte, f *IncomingFrame) error
- type Client
- type ClientFunc
- type ClientProps
- type CloseMessage
- type Conn
- type HandshakeCompletionStage
- type HandshakeHandler
- type IncomingFrame
- type IncomingRequestMessage
- type IncomingResponseMessage
- type OutgoingFrame
- type OutgoingRequestMessage
- type OutgoingResponseMessage
- type RequestPayload
- type Requester
- type ResponseBody
- type ResponseMessage
- type ResponsePayload
- type Session
- type SessionProps
- type TransportHandler
Constants ¶
This section is empty.
Variables ¶
var (
ErrReadyUpgrade = errors.New("session is ready to upgrade")
)
Functions ¶
func DeserializeFrame ¶
func DeserializeFrame(r io.Reader, f *IncomingFrame) error
UnmarshalFrame deserializes a frame from a reader
func DeserializeResponseMessage ¶
func DeserializeResponseMessage(r io.Reader, res *ResponseMessage) error
DeserializeResponseMessage unmarshals a response message from the enclave.
func MarshalFrame ¶
func MarshalFrame(f *OutgoingFrame) ([]byte, error)
MarshalFrame serializes a frame into bytes so that it can be sent to the remote endpoint
func MarshalRequestMessage ¶
func MarshalRequestMessage(m *OutgoingRequestMessage) ([]byte, error)
MarshalRequestMessage serializes an OutgoingRequestMessage to be sent to the remote endpoint
func SerializeBufferIntoFrame ¶
SerializeBufferIntoFrame serializes the contents of a buffer into a RequestMessage
func SerializeFrame ¶
func SerializeFrame(w io.Writer, f *OutgoingFrame) error
SerializeFrame serializes a frame into a writer
func SerializeIntoFrame ¶
SerializeIntoFrame serializes a reader into a frame
func SerializeRequestMessage ¶
func SerializeRequestMessage(w io.Writer, m *OutgoingRequestMessage) error
SerializeRequestMessage serializes an OutgoingRequestMessage into a writer
func UnmarshalCloseMessage ¶
func UnmarshalCloseMessage(p []byte, res *CloseMessage) error
UnmarshalCloseMessage unmarshals a response message from the enclave.
func UnmarshalFrame ¶
func UnmarshalFrame(p []byte, f *IncomingFrame) error
UnmarshalFrame deserializes a frame from bytes
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a fixed pool of connections and distributes work amongst them so that the caller does not need to worry about concurrency
func DialContext ¶
func DialContext(ctx context.Context, props ClientProps) (*Client, error)
DialContext creates a new pool of connections
func (*Client) Request ¶
func (p *Client) Request(ctx context.Context, req RequestPayload) (ResponsePayload, error)
Request issues a request to one of the connections in the pool and retrieves the response. The pool is concurrency safe.
type ClientFunc ¶
ClientFunc allows functions to implement a client
type ClientProps ¶
type ClientProps struct { Conns int Client Requester SessionProps SessionProps }
ClientProps sets up the connection pool
type CloseMessage ¶
type CloseMessage struct{}
CloseMessage is the message type used when notifying the other end that the session will close
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a noise connection to a remote endpoint. It abstracts handling of the session state. A connection is not concurrency safe, if that's a needed property looked into using a FixedConnPool. A Conn does not represent a real network connection, it's an abstraction which uses a client to create the illusion of a Conn, it's the Client implementation what defines the underlying model. A Conn allows mutliplexing of multiple sessions over the same networking connection.
func DialConnContext ¶
DialConnContext creates a new connection and completes the handshake with the remote endpoint. If the handshake fails the Dial will also be considered failed
func (*Conn) Request ¶
func (c *Conn) Request(ctx context.Context, req RequestPayload) (ResponsePayload, error)
Request issues a request in the reader and writes the received response back to the writer
type HandshakeCompletionStage ¶
type HandshakeCompletionStage uint
HandshakeCompletionStage defines the completion stage for the session's handshake
const ( // HandshakeInit the handshake still has to start or is already // in process HandshakeInit HandshakeCompletionStage = iota // Handshake has completed and the session can be upgraded to // handle application input/output HandshakeCompleted // HandshakeClosed the handshake has ended and the session // has been upgraded HandshakeClosed )
type HandshakeHandler ¶
type HandshakeHandler struct {
// contains filtered or unexported fields
}
HandshakeHandler is the handler the session uses to set up the handshake with the remote endpoint
func (*HandshakeHandler) CanUpgrade ¶
func (s *HandshakeHandler) CanUpgrade() bool
CanUpgrade returns whether the Handler is in a HandshakeCompletionStage in which it can be upgraded to an established session
func (*HandshakeHandler) Read ¶
Read reads remote input from an io.Reader, processes that input and writes the output (if any needs to be generated) to the writer
func (*HandshakeHandler) Upgrade ¶
func (s *HandshakeHandler) Upgrade() (*TransportHandler, error)
Upgrade the HandshakeHandler to a TransportHandler so that the application can send/receive payloads
type IncomingFrame ¶
IncomingFrame is the frame used on top of the noise protocol to send messages and be able to multiplex them using the session ID as the identifier
type IncomingRequestMessage ¶
IncomingRequestMessage is the message type used when sending requests to the remote endpoint
type IncomingResponseMessage ¶
IncomingResponseMessage is the message type used when sending a response to a RequestMessage from the remote endpoint
type OutgoingFrame ¶
OutgoingFrame is the frame used on top of the noise protocol to send messages and be able to multiplex them using the session ID as the identifier
type OutgoingRequestMessage ¶
type OutgoingRequestMessage struct {
Request RequestPayload `codec:"Request"`
}
OutgoingRequestMessage is the message type used when sending requests to the remote endpoint
type OutgoingResponseMessage ¶
type OutgoingResponseMessage struct {
Response []byte `codec:"Response"`
}
OutgoingResponseMessage is the message type used when sending a response to a RequestMessage from the remote endpoint
type RequestPayload ¶
type RequestPayload struct { // Method is the method that the request will invoke Method string `codec:"method"` // Args are the arguments for invocation Args interface{} `codec:"args"` }
RequestPayload is the representation of request used for serialization/deserialization
type Requester ¶
type Requester interface { // Request abstracts a request into a reader which contains the // request, and a writer, where the response will be written Request(context.Context, io.Writer, io.Reader) error }
Requester represents a channel between the local endpoint and the remote endpoint that a Conn uses to abstract the underlying transport
type ResponseBody ¶
type ResponseBody struct {
Body ResponsePayload `codec:"Body"`
}
ResponseBody is used to deserialize a received response
type ResponseMessage ¶
type ResponseMessage struct {
Response ResponsePayload
}
ResponseMessage defines the structure of a ResponseMessage. This struct should not be serialized directly, the helper (Serialize/Marshal)ResponseMessage should be used instead
type ResponsePayload ¶
type ResponsePayload struct { // Success is the field that is set in case of a successful // response Success interface{} `codec:"Success"` // Error is the field that is set in case of a failed // response with information on the error's cause Error string `codec:"Error"` }
ResponsePayload is the representation of an ekiden response used for serialization/deserialization
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session holds information on the state of a particular session, handling the protocol messages
func NewSession ¶
func NewSession(props *SessionProps) (*Session, error)
NewSession creates a new noise session with the specific configuration. A session is not concurrency safe until the handshake has completed
func (*Session) CanUpgrade ¶
CanUpgrade checks if the session has finished the handshake and can be upgraded to transport mode
type SessionProps ¶
type SessionProps struct { // Initiator sets the role of this Session instance for the handshake. If // true, this Session initiates the handshake Initiator bool }
SessionProps are the properties to configure the behaviour of a noise session
type TransportHandler ¶
type TransportHandler struct {
// contains filtered or unexported fields
}
TransportHandler is the handler the session uses to send/receive data once the handshake has completed