aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/apiv1-targets.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xdsserver/apiv1-targets.go')
-rw-r--r--lib/xdsserver/apiv1-targets.go44
1 files changed, 34 insertions, 10 deletions
diff --git a/lib/xdsserver/apiv1-targets.go b/lib/xdsserver/apiv1-targets.go
index 978dc75..a7048eb 100644
--- a/lib/xdsserver/apiv1-targets.go
+++ b/lib/xdsserver/apiv1-targets.go
@@ -58,9 +58,16 @@ func (s *APIService) addTarget(c *gin.Context) {
return
}
+ // Retrieve session info
+ sess := s.sessions.Get(c)
+ if sess == nil {
+ common.APIError(c, "Unknown sessions")
+ return
+ }
+
s.Log.Debugln("Add target config: ", cfgArg)
- newTgt, err := s.targets.Add(cfgArg)
+ newTgt, err := s.targets.Add(cfgArg, sess)
if err != nil {
common.APIError(c, err.Error())
return
@@ -77,9 +84,16 @@ func (s *APIService) delTarget(c *gin.Context) {
return
}
+ // Retrieve session info
+ sess := s.sessions.Get(c)
+ if sess == nil {
+ common.APIError(c, "Unknown sessions")
+ return
+ }
+
s.Log.Debugln("Delete target id ", id)
- delEntry, err := s.targets.Delete(id)
+ delEntry, err := s.targets.Delete(id, sess)
if err != nil {
common.APIError(c, err.Error())
return
@@ -190,13 +204,8 @@ func (s *APIService) openTgtTerm(c *gin.Context) {
common.APIError(c, "Unknown sessions")
return
}
- sock := sess.IOSocket
- if sock == nil {
- common.APIError(c, "Websocket not established")
- return
- }
- term, err := s.targets.OpenTerminal(id, tid, sock, sess.ID)
+ term, err := s.targets.OpenTerminal(id, tid, sess)
if err != nil {
common.APIError(c, err.Error())
return
@@ -211,7 +220,15 @@ func (s *APIService) closeTgtTerm(c *gin.Context) {
common.APIError(c, err.Error())
return
}
- term, err := s.targets.CloseTerminal(id, tid)
+
+ // Retrieve session info
+ sess := s.sessions.Get(c)
+ if sess == nil {
+ common.APIError(c, "Unknown sessions")
+ return
+ }
+
+ term, err := s.targets.CloseTerminal(id, tid, sess)
if err != nil {
common.APIError(c, err.Error())
return
@@ -233,7 +250,14 @@ func (s *APIService) resizeTgtTerm(c *gin.Context) {
return
}
- term, err := s.targets.ResizeTerminal(id, tid, sizeArg.Cols, sizeArg.Rows)
+ // Retrieve session info
+ sess := s.sessions.Get(c)
+ if sess == nil {
+ common.APIError(c, "Unknown sessions")
+ return
+ }
+
+ term, err := s.targets.ResizeTerminal(id, tid, sizeArg.Cols, sizeArg.Rows, sess)
if err != nil {
common.APIError(c, err.Error())
return