From 92b9a0eb1f238e153288fb3d2136664c3ceede3c Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 17 Jan 2018 13:18:46 -0500 Subject: [PATCH] Commenting --- connection/authorizationmanager.go | 1 + connection/control_channel.go | 6 +++++- utils/crypto.go | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/connection/authorizationmanager.go b/connection/authorizationmanager.go index 9775f7a..00576cc 100644 --- a/connection/authorizationmanager.go +++ b/connection/authorizationmanager.go @@ -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 } diff --git a/connection/control_channel.go b/connection/control_channel.go index 2954f9e..f312326 100644 --- a/connection/control_channel.go +++ b/connection/control_channel.go @@ -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) diff --git a/utils/crypto.go b/utils/crypto.go index 8186d7b..7e0cbd0 100644 --- a/utils/crypto.go +++ b/utils/crypto.go @@ -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