Commenting

This commit is contained in:
Sarah Jamie Lewis 2018-01-17 13:18:46 -05:00
parent 71685b9c3a
commit 92b9a0eb1f
3 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/s-rah/go-ricochet/utils"
)
// AuthorizationManager helps keep track of permissions for a connection
type AuthorizationManager struct {
Authorizations map[string]bool
}

View File

@ -6,14 +6,18 @@ import (
"github.com/s-rah/go-ricochet/wire/control"
)
// ControlChannel encapsulates logic for the control channel processing
type ControlChannel struct {
channelManager *ChannelManager
}
// Init sets up a control channel
func (ctrl *ControlChannel) Init(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) {
id := cr.GetChannelIdentifier()
@ -33,7 +37,7 @@ func (ctrl *ControlChannel) ProcessChannelResult(cr *Protocol_Data_Control.Chann
return false, nil
}
// ProcessKeepAlive
// ProcessKeepAlive contains logic for responding to keep alives
func (ctrl *ControlChannel) ProcessKeepAlive(ka *Protocol_Data_Control.KeepAlive) (bool, []byte) {
if ka.GetResponseRequested() {
messageBuilder := new(utils.MessageBuilder)

View File

@ -19,6 +19,8 @@ const (
RicochetKeySize = 1024
)
// GetRandNumber is a helper function which returns a random integer, this is
// currently mostly used to generate messageids
func GetRandNumber() *big.Int {
num, err := rand.Int(rand.Reader, big.NewInt(math.MaxUint32))
// If we can't generate random numbers then panicking is probably