Skip to content

Commit

Permalink
Add log error messages in InitServer(), InitClient() and `RunServ…
Browse files Browse the repository at this point in the history
…er()`
  • Loading branch information
Ender-Wang authored and mengelbart committed Nov 3, 2024
1 parent 0c18f3a commit 4a61461
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func (s *Session) RunServer(ctx context.Context) error {
s.storeControlStream(newControlStream(controlStream, s.handleControlMessage))
select {
case <-ctx.Done():
s.si.logger.Error("context done before control stream handshake done")
s.Close()
return ctx.Err()
case <-s.si.serverHandshakeDoneCh:
Expand All @@ -168,9 +169,11 @@ func (s *Session) RunServer(ctx context.Context) error {

func (s *Session) initClient(setup *wire.ServerSetupMessage) error {
if setup.SelectedVersion != wire.CurrentVersion {
s.si.logger.Error("unsupported version", "remote_server_supported_version", setup.SelectedVersion, "client_supported_version", wire.CurrentVersion)
return s.CloseWithError(ErrorCodeUnsupportedVersion, "unsupported version")
}
if err := s.validateRemoteRoleParameter(setup.SetupParameters); err != nil {
s.si.logger.Error("failed to validate remote role parameter", "error", err)
return err
}
s.handshakeDone = true
Expand All @@ -180,9 +183,11 @@ func (s *Session) initClient(setup *wire.ServerSetupMessage) error {
func (s *Session) initServer(setup *wire.ClientSetupMessage) error {
s.controlStream = s.loadControlStream()
if !slices.Contains(setup.SupportedVersions, wire.CurrentVersion) {
s.si.logger.Error("unsupported version", "remote_client_supported_versions", setup.SupportedVersions, "server_supported_version", wire.CurrentVersion)
return s.CloseWithError(ErrorCodeUnsupportedVersion, "unsupported version")
}
if err := s.validateRemoteRoleParameter(setup.SetupParameters); err != nil {
s.si.logger.Error("failed to validate remote role parameter", "error", err)
return err
}
pathParam, ok := setup.SetupParameters[wire.PathParameterKey]
Expand Down

0 comments on commit 4a61461

Please sign in to comment.