Documentation ¶
Index ¶
- Constants
- Variables
- type SecureSession
- func (ss *SecureSession) Close() error
- func (ss *SecureSession) ConnectRequest() ([]byte, error)
- func (ss *SecureSession) GetRemoteID() ([]byte, error)
- func (ss *SecureSession) GetRemoteId() ([]byte, error)deprecated
- func (ss *SecureSession) GetState() int
- func (ss *SecureSession) Unwrap(data []byte) ([]byte, bool, error)
- func (ss *SecureSession) Wrap(data []byte) ([]byte, error)
- type SessionCallbacks
Constants ¶
const ( StateIdle = iota StateNegotiating StateEstablished )
Secure Session states.
const ( STATE_IDLE = StateIdle STATE_NEGOTIATING = StateNegotiating STATE_ESTABLISHED = StateEstablished )
Secure Session states.
Deprecated: Since 0.11. Use "session.State..." constants instead.
Variables ¶
var ( ErrCreateSession = errors.New("failed to create secure session object") ErrDestroySession = errors.New("failed to destroy secure session object") ErrMessageSize = errors.New("failed to get message size") ErrMessageData = errors.New("failed to process message data") ErrNoPublicKey = errors.NewCallbackError("failed to get public key (get_public_key_by_id callback error)") ErrBadRemoteIDLength = errors.NewCallbackError("incorrect remote id length (0)") ErrGetRemoteID = errors.NewCallbackError("failed to get session remote id") ErrMissingClientID = errors.NewWithCode(errors.InvalidParameter, "empty client ID for Secure Session") ErrMissingPrivateKey = errors.NewWithCode(errors.InvalidParameter, "empty client private key for Secure Session") ErrMissingMessage = errors.NewWithCode(errors.InvalidParameter, "empty message for Secure Session") ErrOutOfMemory = errors.NewWithCode(errors.NoMemory, "Secure Session cannot allocate enough memory") // Deprecated: Since 0.14. Use ErrOutOfMemory instead. ErrOverflow = ErrOutOfMemory )
Errors returned by Secure Session.
Functions ¶
This section is empty.
Types ¶
type SecureSession ¶
type SecureSession struct {
// contains filtered or unexported fields
}
SecureSession is a lightweight mechanism for securing any kind of network communication (both private and public networks, including the Internet). It is protocol-agnostic and operates on the 5th layer of the network OSI model (the session layer).
func New ¶
func New(id []byte, signKey *keys.PrivateKey, callbacks SessionCallbacks) (*SecureSession, error)
New makes a new Secure Session with provided peer ID, private key, and callbacks.
func (*SecureSession) Close ¶
func (ss *SecureSession) Close() error
Close destroys a Secure Session.
func (*SecureSession) ConnectRequest ¶
func (ss *SecureSession) ConnectRequest() ([]byte, error)
ConnectRequest generates a connection request that must be sent to the remote peer.
func (*SecureSession) GetRemoteID ¶
func (ss *SecureSession) GetRemoteID() ([]byte, error)
GetRemoteID returns ID of the remote peer.
func (*SecureSession) GetRemoteId
deprecated
func (ss *SecureSession) GetRemoteId() ([]byte, error)
GetRemoteId returns ID of the remote peer.
Deprecated: Since 0.11. Use GetRemoteID() instead.
func (*SecureSession) GetState ¶
func (ss *SecureSession) GetState() int
GetState returns current state of Secure Session.
type SessionCallbacks ¶
type SessionCallbacks interface { GetPublicKeyForId(ss *SecureSession, id []byte) *keys.PublicKey StateChanged(ss *SecureSession, state int) }
SessionCallbacks implements a delegate for SecureSession.