-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
559 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package impl | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jumpserver/wisp/pkg/jms-sdk-go/model" | ||
"github.com/jumpserver/wisp/pkg/logger" | ||
pb "github.com/jumpserver/wisp/protobuf-go/protobuf" | ||
) | ||
|
||
func (j *JMServer) RecordSessionActivity(ctx context.Context, req *pb.SessionActivityRequest) (*pb.StatusResponse, error) { | ||
var ( | ||
status pb.Status | ||
errMsg string | ||
stage model.ActionStage | ||
) | ||
data := req.GetData() | ||
sessionId := req.GetSessionId() | ||
logger.Infof("Request record session %s activity: %s", sessionId, data.String()) | ||
switch data.GetType() { | ||
case pb.ActivityData_ConnectSuccess: | ||
errMsg = "" | ||
stage = model.ConnectSuccess | ||
case pb.ActivityData_ConnectFailed: | ||
errMsg = data.GetError() | ||
stage = model.ConnectFailed | ||
} | ||
if err := j.apiClient.RecordingActivityLog(sessionId, stage, errMsg); err != nil { | ||
logger.Errorf("Record session %s activity failed: %s", sessionId, err) | ||
status.Err = err.Error() | ||
return &pb.StatusResponse{Status: &status}, nil | ||
} | ||
status.Ok = true | ||
return &pb.StatusResponse{Status: &status}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/jumpserver/wisp/pkg/jms-sdk-go/model" | ||
) | ||
|
||
func (s *JMService) RecordingActivityLog(sid string, action model.ActionStage, msgErr string) (err error) { | ||
data := map[string]interface{}{ | ||
"type": action, | ||
} | ||
if msgErr != "" { | ||
data["error"] = msgErr | ||
} | ||
reqURL := fmt.Sprintf(SessionActivityLogURL, sid) | ||
_, err = s.authClient.Post(reqURL, data, nil) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.