xchg

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ERR_XCHG_CONN_WRONG_FRAME_SIZE = "{ERR_XCHG_CONN_WRONG_FRAME_SIZE}"
	ERR_XCHG_CONN_NO_CONNECTION    = "{ERR_XCHG_CONN_NO_CONNECTION}"
	ERR_XCHG_CONN_SENDING_ERROR    = "{ERR_XCHG_CONN_SENDING_ERROR}"
)
View Source
const (
	FrameInit1 = byte(0x01) // 1 -> 2: [addr1]
	FrameInit2 = byte(0x02) // 2 -> 1: [addr2]
	FrameInit3 = byte(0x03) // 2 -> 1: [enc(secret2, addr1)] // client, prove it is you
	FrameInit4 = byte(0x04) // 1 -> 2: [enc(secret2, addr2)] // it is me, client
	FrameInit5 = byte(0x05) // 1 -> 2: [enc(secret1, addr2)] // xchg,prove it is you
	FrameInit6 = byte(0x06) // 2 -> 1: [enc(secret1, addr1)] // it is me, xchg

	FrameResolveAddress  = byte(0x10) // 1 -> 2: [addr3]
	FrameResolvedAddress = byte(0x11) // 2 -> 1: [sid3]

	FrameCall     = byte(0x20) // 1 -> 2: [sid3][call_frame] --- 2 -> 3: [call_frame]
	FrameResponse = byte(0x21) // 3 -> 2: [response_frame] --- 2 -> 1: [response_frame]
	FrameError    = byte(0xFF)
)
View Source
const Base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
View Source
const (
	ERR_XCHG_ACCESS_DENIED = "{ERR_XCHG_ACCESS_DENIED}"
)
View Source
const (
	ERR_XCHG_TR_WRONG_FRAME = "{ERR_XCHG_TR_WRONG_FRAME}"
)
View Source
const (
	TransactionHeaderSize = 32
)

Variables

This section is empty.

Functions

func AddressForPublicKey added in v0.0.10

func AddressForPublicKey(publicKey *rsa.PublicKey) string

func AddressForPublicKeyBS added in v0.0.10

func AddressForPublicKeyBS(publicKeyBS []byte) string

func NormalizeAddress added in v0.0.10

func NormalizeAddress(address string) string

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection() *Connection

func (*Connection) Dispose added in v0.0.11

func (c *Connection) Dispose()

func (*Connection) InitIncomingConnection

func (c *Connection) InitIncomingConnection(conn net.Conn, processor ITransactionProcessor)

func (*Connection) InitOutgoingConnection

func (c *Connection) InitOutgoingConnection(host string, processor ITransactionProcessor)

func (*Connection) IsClosed

func (c *Connection) IsClosed() bool

func (*Connection) IsIncoming

func (c *Connection) IsIncoming() bool

func (*Connection) IsOutgoing

func (c *Connection) IsOutgoing() bool

func (*Connection) ReceivedBytes

func (c *Connection) ReceivedBytes() uint64

func (*Connection) ReceivedFrames

func (c *Connection) ReceivedFrames() uint64

func (*Connection) Send

func (c *Connection) Send(transaction *Transaction) (err error)

func (*Connection) SendError

func (c *Connection) SendError(transaction *Transaction, err error)

func (*Connection) SentBytes

func (c *Connection) SentBytes() uint64

func (*Connection) SentFrames

func (c *Connection) SentFrames() uint64

func (*Connection) Start

func (c *Connection) Start()

func (*Connection) State added in v0.0.13

func (c *Connection) State() (state ConnectionState)

func (*Connection) Stop

func (c *Connection) Stop()

type ConnectionState added in v0.0.5

type ConnectionState struct {
	Host           string
	ReceivedBytes  uint64
	SentBytes      uint64
	ReceivedFrames uint64
	SentFrames     uint64

	Connected bool
	Started   bool
	Stopping  bool
}

type ITransactionProcessor

type ITransactionProcessor interface {
	Connected()
	ProcessTransaction(transaction *Transaction)
	Disconnected()
}

type Transaction

type Transaction struct {
	// Header - 32 bytes + Data
	Signature       byte
	ProtocolVersion byte
	FrameType       byte
	Reserved        byte
	FrameLen        uint32
	SID             uint64
	TransactionId   uint64
	SessionId       uint64
	Data            []byte

	// Routing Data
	ResponseSender        TransactionSender
	OriginalTransactionId uint64

	// Execution Result
	Complete bool
	Result   []byte
	Err      error
}

func NewTransaction

func NewTransaction(frameType byte, targetSID uint64, transactionId uint64, sessionId uint64, data []byte) *Transaction

func Parse

func Parse(frame []byte) (tr *Transaction, err error)

type TransactionSender

type TransactionSender interface {
	Send(transaction *Transaction) (err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL