Skip to content

Commit

Permalink
perf: add comment for appletHost session
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc committed Aug 1, 2024
1 parent bc0f3d0 commit c383015
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/jms-sdk-go/model/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Session struct {
UserID string `json:"user_id"`
AssetID string `json:"asset_id"`
AccountID string `json:"account_id"`
Comment string `json:"comment,omitempty"`
}

type ReplayVersion string
Expand Down
13 changes: 13 additions & 0 deletions pkg/session/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,15 @@ func (s *Server) Create(ctx *gin.Context, opts ...TunnelOption) (sess TunnelSess
sess.AppletOpts = opt.appletOpt
sess.VirtualAppOpts = opt.virtualAppOPt
sess.AuthInfo = opt.authInfo
comment := ""
if opt.appletOpt != nil {
sess.RemoteApp = &opt.appletOpt.Applet
comment = fmt.Sprintf(appletCommentTmpl,
opt.appletOpt.Host.String(),
opt.appletOpt.Account.String(),
opt.appletOpt.Applet.Name)
}

sess.User = opt.User
sess.ExpireInfo = opt.ExpireInfo
sess.Permission = &perm
Expand All @@ -273,6 +279,7 @@ func (s *Server) Create(ctx *gin.Context, opts ...TunnelOption) (sess TunnelSess
UserID: sess.User.ID,
AssetID: sess.Asset.ID,
AccountID: opt.Account.ID,
Comment: comment,
}
sess.ConnectedCallback = s.RegisterConnectedCallback(jmsSession)
sess.ConnectedSuccessCallback = s.RegisterConnectedSuccessCallback(jmsSession)
Expand Down Expand Up @@ -496,3 +503,9 @@ func ValidReplayDirname(dirname string) bool {
_, err := time.Parse(recordDirTimeFormat, dirname)
return err == nil
}

const appletCommentTmpl = `
AppletHost: %s
Account: %s
Applet:%s
`

0 comments on commit c383015

Please sign in to comment.