Documentation ¶
Index ¶
- Constants
- func AddressForPublicKey(publicKey *rsa.PublicKey) string
- func AddressForPublicKeyBS(publicKeyBS []byte) string
- func NeedToChangeNode(err error) bool
- func NeedToMakeSession(err error) bool
- func NormalizeAddress(address string) string
- type Connection
- func (c *Connection) Dispose()
- func (c *Connection) InitIncomingConnection(conn net.Conn, processor ITransactionProcessor, internalId string)
- func (c *Connection) InitOutgoingConnection(host string, processor ITransactionProcessor, internalId string)
- func (c *Connection) IsClosed() bool
- func (c *Connection) IsIncoming() bool
- func (c *Connection) IsOutgoing() bool
- func (c *Connection) ReceivedBytes() uint64
- func (c *Connection) ReceivedFrames() uint64
- func (c *Connection) Send(transaction *Transaction) (err error)
- func (c *Connection) SendError(transaction *Transaction, err error)
- func (c *Connection) SentBytes() uint64
- func (c *Connection) SentFrames() uint64
- func (c *Connection) Start()
- func (c *Connection) State() (state ConnectionState)
- func (c *Connection) Stop()
- type ConnectionState
- type ITransactionProcessor
- type Transaction
- type TransactionSender
Constants ¶
View Source
const ( ERR_XCHG_ACCESS_DENIED = "{ERR_XCHG_ACCESS_DENIED}" // Base Connection 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}" // Transaction ERR_XCHG_TR_WRONG_FRAME = "{ERR_XCHG_TR_WRONG_FRAME}" // Client Connection // Regular Call ERR_XCHG_CL_CONN_CALL_WRONG_FUNCTION_LEN = "{ERR_XCHG_CL_CONN_CALL_WRONG_FUNCTION_LEN}" ERR_XCHG_CL_CONN_CALL_SEARCHING_NODE = "{ERR_XCHG_CL_CONN_CALL_SEARCHING_NODE}" ERR_XCHG_CL_CONN_CALL_NO_LOCAL_PRIVATE_KEY = "{ERR_XCHG_CL_CONN_CALL_NO_LOCAL_PRIVATE_KEY}" ERR_XCHG_CL_CONN_CALL_NO_ROUTE_TO_PEER = "{ERR_XCHG_CL_CONN_CALL_NO_ROUTE_TO_PEER}" ERR_XCHG_CL_CONN_CALL_RESP_LEN = "{ERR_XCHG_CL_CONN_CALL_RESP_LEN}" ERR_XCHG_CL_CONN_CALL_RESP_STATUS_BYTE = "{ERR_XCHG_CL_CONN_CALL_RESP_STATUS_BYTE}" ERR_XCHG_CL_CONN_CALL_ENC = "{ERR_XCHG_CL_CONN_CALL_ENC}" ERR_XCHG_CL_CONN_CALL_ERR = "{ERR_XCHG_CL_CONN_CALL_ERR}" ERR_XCHG_CL_CONN_CALL_FROM_PEER = "{ERR_XCHG_CL_CONN_FROM_PEER}" // Auth ERR_XCHG_CL_CONN_AUTH_GET_NONCE = "{ERR_XCHG_CL_CONN_AUTH_GET_NONCE}" ERR_XCHG_CL_CONN_AUTH_WRONG_NONCE_LEN = "{ERR_XCHG_CL_CONN_AUTH_WRONG_NONCE_LEN}" ERR_XCHG_CL_CONN_AUTH_NO_LOCAL_PRIVATE_KEY = "{ERR_XCHG_CL_CONN_AUTH_NO_LOCAL_PRIVATE_KEY}" ERR_XCHG_CL_CONN_AUTH_ENC = "{ERR_XCHG_CL_CONN_AUTH_ENC}" ERR_XCHG_CL_CONN_AUTH_AUTH = "{ERR_XCHG_CL_CONN_AUTH_AUTH}" ERR_XCHG_CL_CONN_AUTH_DECR = "{ERR_XCHG_CL_CONN_AUTH_DECR}" ERR_XCHG_CL_CONN_AUTH_WRONG_AUTH_RESP_LEN = "{ERR_XCHG_CL_CONN_AUTH_WRONG_AUTH_RESP_LEN}" // Peer Connection ERR_XCHG_PEER_CONN_LOSS = "{ERR_XCHG_PEER_CONN_LOSS}" ERR_XCHG_PEER_CONN_TR_TIMEOUT = "{ERR_XCHG_PEER_CONN_TR_TIMEOUT}" ERR_XCHG_PEER_CONN_REQ_SID_SIZE = "{ERR_XCHG_PEER_CONN_REQ_SID_SIZE}" ERR_XCHG_PEER_CONN_WRONG_PROT_VERSION = "{ERR_XCHG_PEER_CONN_WRONG_PROT_VERSION}" ERR_XCHG_PEER_CONN_RCVD_ERR = "{ERR_XCHG_PEER_CONN_RCVD_ERR}" // Server Connection ERR_XCHG_SRV_CONN_WRONG_SESSION = "{ERR_XCHG_SRV_CONN_WRONG_SESSION}" ERR_XCHG_SRV_CONN_DECR = "{ERR_XCHG_SRV_CONN_DECR}" ERR_XCHG_SRV_CONN_WRONG_LEN9 = "{ERR_XCHG_SRV_CONN_WRONG_LEN9}" ERR_XCHG_SRV_CONN_WRONG_NONCE = "{ERR_XCHG_SRV_CONN_WRONG_NONCE}" ERR_XCHG_SRV_CONN_WRONG_LEN1 = "{ERR_XCHG_SRV_CONN_WRONG_LEN1}" ERR_XCHG_SRV_CONN_WRONG_LEN_FN = "{ERR_XCHG_SRV_CONN_WRONG_LEN_FN}" ERR_XCHG_SRV_CONN_AUTH_DATA_LEN4 = "{ERR_XCHG_SRV_CONN_AUTH_DATA_LEN4}" ERR_XCHG_SRV_CONN_NOT_IMPL = "{ERR_XCHG_SRV_CONN_NOT_IMPL}" ERR_XCHG_SRV_CONN_AUTH_DATA_LEN_NONCE = "{ERR_XCHG_SRV_CONN_AUTH_DATA_LEN_NONCE}" ERR_XCHG_SRV_CONN_AUTH_DATA_LEN_PK = "{ERR_XCHG_SRV_CONN_AUTH_DATA_LEN_PK}" ERR_XCHG_SRV_CONN_AUTH_WRONG_NONCE = "{ERR_XCHG_SRV_CONN_AUTH_WRONG_NONCE}" // Router ERR_XCHG_ROUTER_CONFIG_IS_DIRECTORY = "{ERR_XCHG_ROUTER_CONFIG_IS_DIRECTORY}" ERR_XCHG_ROUTER_CONN_WRONG_FRAME_TYPE = "{ERR_XCHG_ROUTER_CONN_WRONG_FRAME_TYPE}" ERR_XCHG_ROUTER_CONN_WRONG_PROTOCOL_VERSION = "{ERR_XCHG_ROUTER_CONN_WRONG_PROTOCOL_VERSION}" ERR_XCHG_ROUTER_CONN_WRONG_PUBLIC_KEY_SIZE = "{ERR_XCHG_ROUTER_CONN_WRONG_PUBLIC_KEY_SIZE}" ERR_XCHG_ROUTER_CONN_ENC = "{ERR_XCHG_ROUTER_CONN_ENC}" ERR_XCHG_ROUTER_CONN_DECR4 = "{ERR_XCHG_ROUTER_CONN_DECR4}" ERR_XCHG_ROUTER_CONN_DECR5 = "{ERR_XCHG_ROUTER_CONN_DECR5}" ERR_XCHG_ROUTER_CONN_NO_ROUTE_TO_PEER = "{ERR_XCHG_ROUTER_CONN_NO_ROUTE_TO_PEER}" ERR_XCHG_ROUTER_SERVER_ALREADY_STARTED = "{ERR_XCHG_ROUTER_SERVER_ALREADY_STARTED}" ERR_XCHG_ROUTER_SERVER_IS_NOT_STARTED = "{ERR_XCHG_ROUTER_SERVER_IS_NOT_STARTED}" ERR_XCHG_ROUTER_ALREADY_STARTED = "{ERR_XCHG_ROUTER_ALREADY_STARTED}" ERR_XCHG_ROUTER_IS_NOT_STARTED = "{ERR_XCHG_ROUTER_IS_NOT_STARTED}" // Other ERR_SIMPLE_SERVER_FUNC_IS_NOT_IMPL = "{ERR_SIMPLE_SERVER_FUNC_IS_NOT_IMPL}" )
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] 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 AddressBytesSize = 30
View Source
const AddressSize = int((AddressBytesSize * 8) / 5)
View Source
const Base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
View Source
const (
TransactionHeaderSize = 32
)
Variables ¶
This section is empty.
Functions ¶
func AddressForPublicKey ¶ added in v0.0.10
func AddressForPublicKeyBS ¶ added in v0.0.10
func NeedToChangeNode ¶ added in v0.0.19
Reason to change node
func NeedToMakeSession ¶ added in v0.0.19
Reason to make session
func NormalizeAddress ¶ added in v0.0.10
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, internalId string)
func (*Connection) InitOutgoingConnection ¶
func (c *Connection) InitOutgoingConnection(host string, processor ITransactionProcessor, internalId string)
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 `json:"host"` ReceivedBytes uint64 `json:"received_bytes"` SentBytes uint64 `json:"sent_bytes"` ReceivedFrames uint64 `json:"received_frames"` SentFrames uint64 `json:"sent_frames"` Connected bool `json:"connected"` Started bool `json:"started"` Stopping bool `json:"stopping"` }
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 BeginDT time.Time AddressSrc string AddressDest string // Execution Result Complete bool Result []byte Err error }
func NewTransaction ¶
func Parse ¶
func Parse(frame []byte) (tr *Transaction, err error)
func (*Transaction) String ¶ added in v0.0.16
func (c *Transaction) String() string
type TransactionSender ¶
type TransactionSender interface {
Send(transaction *Transaction) (err error)
}
Click to show internal directories.
Click to hide internal directories.