Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPacket(p []byte) protocol.Error
- func Decrypt(payload []byte, cipher protocol.Cipher) (frames []byte, err protocol.Error)
- func DecryptRouting(packet []byte, cipher protocol.Cipher) (err protocol.Error)
- func Encrypt(frames []byte, cipher protocol.Cipher) (payload []byte, err protocol.Error)
- func EncryptRouting(packet []byte, cipher protocol.Cipher) (err protocol.Error)
- func GetPacketNumber(p []byte) uint64
- func GetPayload(p []byte) []byte
- type Addr
- func (addr Addr) AppID() uint16
- func (addr Addr) PlanetID() uint16
- func (addr Addr) RouterID() uint32
- func (addr Addr) SetAppID(id uint32)
- func (addr Addr) SetPlanetID(id uint16)
- func (addr Addr) SetRouterID(id uint32)
- func (addr Addr) SetSocietyID(id uint32)
- func (addr Addr) SetUserID(id uint32)
- func (addr Addr) SocietyID() uint32
- func (addr Addr) UserID() uint32
- type AppMultiplexer
- type Connection
- func (conn *Connection) Addr() [16]byte
- func (conn *Connection) AddrType() NetworkLinkNextHeaderID
- func (conn *Connection) Cipher() Cipher
- func (conn *Connection) DelegateUserID() [32]byte
- func (conn *Connection) DelegateUserType() UserType
- func (conn *Connection) DomainName() string
- func (conn *Connection) ID() uint32
- func (conn *Connection) MTU() int
- func (conn *Connection) MakeIncomeStream(streamID uint32) (st protocol.Stream, err protocol.Error)
- func (conn *Connection) MakeOutcomeStream(streamID uint32) (st *Stream, err protocol.Error)
- func (conn *Connection) MakeSubscriberStream() (st *Stream)
- func (conn *Connection) Receive(packet []byte)
- func (conn *Connection) SetThingID(thingID [32]byte)
- func (conn *Connection) ThingID() [32]byte
- func (conn *Connection) UserID() [32]byte
- func (conn *Connection) UserType() UserType
- type OSMultiplexer
- func (osMux *OSMultiplexer) HeaderID() protocol.NetworkLinkNextHeaderID
- func (osMux *OSMultiplexer) Init()
- func (osMux *OSMultiplexer) Receive(conn protocol.NetworkLinkConnection, packet []byte)
- func (osMux *OSMultiplexer) RegisterAppMultiplexer(appMux protocol.NetworkTransportMultiplexer)
- func (osMux *OSMultiplexer) Shutdown()
- func (osMux *OSMultiplexer) UnRegisterAppMultiplexer(appMux protocol.NetworkTransportMultiplexer)
- type Stream
- func (st *Stream) Authorize() (err protocol.Error)
- func (st *Stream) Close()
- func (st *Stream) Connection() protocol.Connection
- func (st *Stream) ID() uint32
- func (st *Stream) IncomeData() protocol.Codec
- func (st *Stream) OutcomeData() protocol.Codec
- func (st *Stream) ProtocolID() protocol.NetworkApplicationProtocolID
- func (st *Stream) SendRequest() (err protocol.Error)
- func (st *Stream) SendResponse() (err protocol.Error)
- func (st *Stream) Service() protocol.Service
- func (st *Stream) SetIncomeData(codec protocol.Codec)
- func (st *Stream) SetOutcomeData(codec protocol.Codec)
- func (st *Stream) SetService(service protocol.Service)
- func (st *Stream) SetState(state protocol.ConnectionState)
- func (st *Stream) State() chan protocol.ConnectionState
- func (st *Stream) Status() protocol.ConnectionState
- type StreamPool
Constants ¶
const ( // MinPacketLen is minimum packet length of GP packet // 320bit header + 128bit min payload MinPacketLen = 56 )
Variables ¶
var ( ErrPacketTooShort = er.New("urn:giti:gp.protocol:error:packet-too-short").SetDetail(protocol.LanguageEnglish, errorEnglishDomain, "Packet Too Short", "Giti packet is empty or too short than standard header. It must include 44Byte header plus 16Byte min Payload", "", "").Save() ErrPacketArrivedAnterior = er.New("urn:giti:gp.protocol:error:packet-arrived-anterior").SetDetail(protocol.LanguageEnglish, errorEnglishDomain, "Packet Arrived Anterior", "New packet arrive before some expected packet arrived. Usually cause of drop packet detection or high latency occur for some packet", "", "").Save() ErrPacketArrivedPosterior = er.New("urn:giti:gp.protocol:error:packet-arrived-posterior").SetDetail(protocol.LanguageEnglish, errorEnglishDomain, "Packet Arrived Posterior", "New packet arrive after some expected packet arrived. Usually cause of drop packet detection or high latency occur for some packet", "", "").Save() )
Errors
var (
AddrNil = Addr{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
)
Some global address
Functions ¶
func CheckPacket ¶
CheckPacket will check packet for any bad situation! Always check packet before use any other packet methods otherwise panic occur!
func DecryptRouting ¶
DecryptRouting usually use in encrypted connection from OS to GP Router!
func EncryptRouting ¶
EncryptRouting usually use in encrypted connection from OS to GP Router!
func GetPayload ¶
GetPayload returns payload that means all data after packetNumber
Types ¶
type Addr ¶
type Addr [16]byte
Addr present GP address with needed methods
func GetDestinationAddr ¶
GetDestinationAddr returns full destination GP address.
func GetSourceAddr ¶
GetSourceAddr returns full source GP address.
func (Addr) SetPlanetID ¶
SetPlanetID set planet ID in given Addr.
func (Addr) SetRouterID ¶
SetRouterID set router ID in given Addr.
func (Addr) SetSocietyID ¶
SetSocietyID set society ID in given Addr.
type AppMultiplexer ¶
type AppMultiplexer struct{}
func (*AppMultiplexer) HeaderID ¶
func (appMux *AppMultiplexer) HeaderID() protocol.NetworkLinkNextHeaderID
func (*AppMultiplexer) Init ¶
func (appMux *AppMultiplexer) Init() (err protocol.Error)
MakeGPNetwork register app to OS GP router and start handle income GP packets.
func (*AppMultiplexer) Receive ¶
func (appMux *AppMultiplexer) Receive(linkConn protocol.NetworkLinkConnection, packet []byte)
Receive handle GP packet with any application protocol and response just some basic data! Protocol Standard : https://github.com/GeniusesGroup/RFCs/blob/master/Giti-Network.md
func (*AppMultiplexer) Shutdown ¶
func (appMux *AppMultiplexer) Shutdown()
Shutdown the listener when the application closes or force to closes by not recovered panic!
type Connection ¶
type Connection struct { /* Connection data */ ID [32]byte StreamPool StreamPool State protocol.ConnectionState Weight protocol.ConnectionWeight /* Security data */ AccessControl authorization.AccessControl connection.Metric // contains filtered or unexported fields }
Connection indicate the https://github.com/balacode/udpt/blob/main/sender.go
func EstablishNewConnectionByDomainID ¶
func EstablishNewConnectionByDomainID(domainID [32]byte) (conn *Connection, err protocol.Error)
EstablishNewConnectionByDomainID make new connection by peer domain ID and initialize it!
func EstablishNewConnectionByPeerAdd ¶
func EstablishNewConnectionByPeerAdd(gpAddr Addr) (conn *Connection, err protocol.Error)
EstablishNewConnectionByPeerAdd make new connection by peer GP and initialize it!
func MakeNewGuestConnection ¶
func MakeNewGuestConnection() (conn *Connection, err protocol.Error)
MakeNewGuestConnection make new connection and register on given stream due to it is first attempt connect to server!
func (*Connection) Addr ¶
func (conn *Connection) Addr() [16]byte
func (*Connection) AddrType ¶
func (conn *Connection) AddrType() NetworkLinkNextHeaderID
func (*Connection) Cipher ¶
func (conn *Connection) Cipher() Cipher
func (*Connection) DelegateUserID ¶
func (conn *Connection) DelegateUserID() [32]byte
func (*Connection) DelegateUserType ¶
func (conn *Connection) DelegateUserType() UserType
func (*Connection) DomainName ¶
func (conn *Connection) DomainName() string
func (*Connection) ID ¶
func (conn *Connection) ID() uint32
func (*Connection) MTU ¶
func (conn *Connection) MTU() int
func (*Connection) MakeIncomeStream ¶
MakeIncomeStream make and return the new stream with income ID! Never make Stream instance by hand, This function can improve by many ways!
func (*Connection) MakeOutcomeStream ¶
func (conn *Connection) MakeOutcomeStream(streamID uint32) (st *Stream, err protocol.Error)
MakeOutcomeStream make and return the new stream with outcome ID! Never make Stream instance by hand, This function can improve by many ways!
func (*Connection) MakeSubscriberStream ¶
func (conn *Connection) MakeSubscriberStream() (st *Stream)
MakeSubscriberStream make new Publish–Subscribe stream!
func (*Connection) Receive ¶
func (conn *Connection) Receive(packet []byte)
Receive use for default and empty switch port due to non of ports can be nil!
func (*Connection) SetThingID ¶
func (conn *Connection) SetThingID(thingID [32]byte)
SetThingID set thingID only if it is not set before
func (*Connection) ThingID ¶
func (conn *Connection) ThingID() [32]byte
func (*Connection) UserID ¶
func (conn *Connection) UserID() [32]byte
func (*Connection) UserType ¶
func (conn *Connection) UserType() UserType
type OSMultiplexer ¶
type OSMultiplexer struct {
// contains filtered or unexported fields
}
func (*OSMultiplexer) HeaderID ¶
func (osMux *OSMultiplexer) HeaderID() protocol.NetworkLinkNextHeaderID
func (*OSMultiplexer) Init ¶
func (osMux *OSMultiplexer) Init()
MakeGPNetwork register app to OS GP router and start handle income GP packets.
func (*OSMultiplexer) Receive ¶
func (osMux *OSMultiplexer) Receive(conn protocol.NetworkLinkConnection, packet []byte)
Receive handle GP packet with any application protocol and response just some basic data! Protocol Standard : https://github.com/GeniusesGroup/RFCs/blob/master/Giti-Network.md
func (*OSMultiplexer) RegisterAppMultiplexer ¶
func (osMux *OSMultiplexer) RegisterAppMultiplexer(appMux protocol.NetworkTransportMultiplexer)
RegisterAppMultiplexer will register multiplexer only if it is GP multiplexer.
func (*OSMultiplexer) Shutdown ¶
func (osMux *OSMultiplexer) Shutdown()
Shutdown the listener when the application closes or force to closes by not recovered panic.
func (*OSMultiplexer) UnRegisterAppMultiplexer ¶
func (osMux *OSMultiplexer) UnRegisterAppMultiplexer(appMux protocol.NetworkTransportMultiplexer)
type Stream ¶
type Stream struct { Weight protocol.ConnectionWeight // 16 queue for priority weight of the streams exist. /* Metrics */ TotalPacket uint32 // Expected packets count that must received! PacketReceived uint32 // Count of packets received! LastPacketID uint32 // Last send or received Packet use to know order of packets! PacketDropCount uint8 // Count drop packets to prevent some attacks type! // contains filtered or unexported fields }
Stream use to send or receive data on specific connection. It can pass to logic layer to give data access to developer! Data flow can be up to down (parse raw income data) or down to up (encode app data with respect MTU) If OutcomePayload not present stream is UnidirectionalStream otherwise it is BidirectionalStream!
func MakeNewStream ¶
MakeNewStream use to make new stream without any connection exist yet! TODO::: due to IPv4&&IPv6 support we need this func! Remove it when remove those support!
func (*Stream) Connection ¶
func (st *Stream) Connection() protocol.Connection
func (*Stream) IncomeData ¶
func (*Stream) OutcomeData ¶
func (*Stream) ProtocolID ¶
func (st *Stream) ProtocolID() protocol.NetworkApplicationProtocolID
func (*Stream) SendRequest ¶
SendRequest use for default and empty switch port due to non of ports can be nil! SendAndWait register stream in send pool and block caller until response ready to read.
func (*Stream) SendResponse ¶
SendResponse register stream in send pool. Usually use to send response stream.
func (*Stream) SetIncomeData ¶
func (*Stream) SetOutcomeData ¶
func (*Stream) SetService ¶
SetService check and if it is first time register given service for the stream.
func (*Stream) SetState ¶
func (st *Stream) SetState(state protocol.ConnectionState)
SetState change state of stream and send notification on stream StateChannel.
func (*Stream) State ¶
func (st *Stream) State() chan protocol.ConnectionState
func (*Stream) Status ¶
func (st *Stream) Status() protocol.ConnectionState
type StreamPool ¶
type StreamPool struct {
// contains filtered or unexported fields
}
StreamPool set & get streams in a pool by ID!
func (*StreamPool) OutcomeStream ¶
func (sp *StreamPool) OutcomeStream(service protocol.Service) (stream protocol.Stream, err protocol.Error)
OutcomeStream make the stream and returns it!
func (*StreamPool) RegisterStream ¶
func (sp *StreamPool) RegisterStream(st protocol.Stream)
RegisterStream save given Stream to pool