mirror of
https://github.com/veops/oneterm.git
synced 2025-10-20 06:04:35 +08:00
feat(api): share
This commit is contained in:
@@ -255,10 +255,13 @@ func DoConnect(ctx *gin.Context, ws *websocket.Conn) (sess *gsession.Session, er
|
||||
currentUser, _ := acl.GetSessionFromCtx(ctx)
|
||||
|
||||
assetId, accountId := cast.ToInt(ctx.Param("asset_id")), cast.ToInt(ctx.Param("account_id"))
|
||||
fmt.Println("--------------------------------------", assetId, accountId)
|
||||
asset, account, gateway, err := util.GetAAG(assetId, accountId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println("--------------------------------------", *asset)
|
||||
fmt.Println("--------------------------------------", *account)
|
||||
|
||||
sess = gsession.NewSession(ctx)
|
||||
sess.Ws = ws
|
||||
@@ -277,6 +280,8 @@ func DoConnect(ctx *gin.Context, ws *websocket.Conn) (sess *gsession.Session, er
|
||||
Status: model.SESSIONSTATUS_ONLINE,
|
||||
ShareId: cast.ToInt(ctx.Value("shareId")),
|
||||
}
|
||||
fmt.Printf("==============%+v\n", *sess)
|
||||
fmt.Printf("==============%+v\n", *sess.Session)
|
||||
if sess.IsSsh() {
|
||||
w, h := cast.ToInt(ctx.Query("w")), cast.ToInt(ctx.Query("h"))
|
||||
sess.SshParser = gsession.NewParser(sess.SessionId, w, h)
|
||||
@@ -304,14 +309,16 @@ func DoConnect(ctx *gin.Context, ws *websocket.Conn) (sess *gsession.Session, er
|
||||
ctx.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
if !acl.IsAdmin(currentUser) && !HasAuthorization(ctx, assetId, accountId) {
|
||||
if !acl.IsAdmin(currentUser) && !hasAuthorization(ctx, assetId, accountId) {
|
||||
err = &ApiError{Code: ErrUnauthorized}
|
||||
ctx.AbortWithError(http.StatusForbidden, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
switch strings.Split(sess.Protocol, ":")[0] {
|
||||
case "ssh":
|
||||
fmt.Println("-----------------------------------------------fuckkkkkkkkkkkkkkkkkkkkkkkkkkk")
|
||||
go connectSsh(ctx, sess, asset, account, gateway)
|
||||
case "vnc", "rdp":
|
||||
go connectGuacd(ctx, sess, asset, account, gateway)
|
||||
|
Reference in New Issue
Block a user