Commenting
This commit is contained in:
parent
71685b9c3a
commit
92b9a0eb1f
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/s-rah/go-ricochet/utils"
|
"github.com/s-rah/go-ricochet/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AuthorizationManager helps keep track of permissions for a connection
|
||||||
type AuthorizationManager struct {
|
type AuthorizationManager struct {
|
||||||
Authorizations map[string]bool
|
Authorizations map[string]bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,18 @@ import (
|
||||||
"github.com/s-rah/go-ricochet/wire/control"
|
"github.com/s-rah/go-ricochet/wire/control"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
// ControlChannel encapsulates logic for the control channel processing
|
||||||
type ControlChannel struct {
|
type ControlChannel struct {
|
||||||
channelManager *ChannelManager
|
channelManager *ChannelManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init sets up a control channel
|
||||||
func (ctrl *ControlChannel) Init(channelManager *ChannelManager) {
|
func (ctrl *ControlChannel) Init(channelManager *ChannelManager) {
|
||||||
ctrl.channelManager = channelManager
|
ctrl.channelManager = channelManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProcessChannelResult contains the logic for processing a channelresult message
|
||||||
func (ctrl *ControlChannel) ProcessChannelResult(cr *Protocol_Data_Control.ChannelResult) (bool, error) {
|
func (ctrl *ControlChannel) ProcessChannelResult(cr *Protocol_Data_Control.ChannelResult) (bool, error) {
|
||||||
id := cr.GetChannelIdentifier()
|
id := cr.GetChannelIdentifier()
|
||||||
|
|
||||||
|
@ -33,7 +37,7 @@ func (ctrl *ControlChannel) ProcessChannelResult(cr *Protocol_Data_Control.Chann
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessKeepAlive
|
// ProcessKeepAlive contains logic for responding to keep alives
|
||||||
func (ctrl *ControlChannel) ProcessKeepAlive(ka *Protocol_Data_Control.KeepAlive) (bool, []byte) {
|
func (ctrl *ControlChannel) ProcessKeepAlive(ka *Protocol_Data_Control.KeepAlive) (bool, []byte) {
|
||||||
if ka.GetResponseRequested() {
|
if ka.GetResponseRequested() {
|
||||||
messageBuilder := new(utils.MessageBuilder)
|
messageBuilder := new(utils.MessageBuilder)
|
||||||
|
|
|
@ -19,6 +19,8 @@ const (
|
||||||
RicochetKeySize = 1024
|
RicochetKeySize = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetRandNumber is a helper function which returns a random integer, this is
|
||||||
|
// currently mostly used to generate messageids
|
||||||
func GetRandNumber() *big.Int {
|
func GetRandNumber() *big.Int {
|
||||||
num, err := rand.Int(rand.Reader, big.NewInt(math.MaxUint32))
|
num, err := rand.Int(rand.Reader, big.NewInt(math.MaxUint32))
|
||||||
// If we can't generate random numbers then panicking is probably
|
// If we can't generate random numbers then panicking is probably
|
||||||
|
|
Reference in New Issue