diff --git a/README.md b/README.md
index 6dcc8995..efec3671 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ https://next.typesafe.cn/ 账号:test 密码:test
## License
-Next Terminal 使用 [AGPL-3.0](./LICENSE) 开源协议,请自觉准守。
+Next Terminal 使用 [AGPL-3.0](./LICENSE) 开源协议,请自觉遵守。
## 赞助支持
diff --git a/server/api/session.go b/server/api/session.go
index 631e7cd5..75bf3008 100644
--- a/server/api/session.go
+++ b/server/api/session.go
@@ -47,7 +47,7 @@ func (api SessionApi) SessionPagingEndpoint(c echo.Context) error {
if status == constant.Disconnected && len(items[i].Recording) > 0 {
var recording string
- if items[i].Mode == constant.Naive || items[i].Mode == constant.Terminal {
+ if items[i].Mode == constant.Native || items[i].Mode == constant.Terminal {
recording = items[i].Recording
} else {
recording = items[i].Recording + "/recording"
@@ -170,8 +170,8 @@ func (api SessionApi) SessionCreateEndpoint(c echo.Context) error {
assetId := c.QueryParam("assetId")
mode := c.QueryParam("mode")
- if mode == constant.Naive {
- mode = constant.Naive
+ if mode == constant.Native {
+ mode = constant.Native
} else {
mode = constant.Guacd
}
@@ -526,7 +526,7 @@ func (api SessionApi) SessionRecordingEndpoint(c echo.Context) error {
}
var recording string
- if s.Mode == constant.Naive || s.Mode == constant.Terminal {
+ if s.Mode == constant.Native || s.Mode == constant.Terminal {
recording = s.Recording
} else {
recording = s.Recording + "/recording"
diff --git a/server/app/app.go b/server/app/app.go
index b4b732da..5e12766c 100644
--- a/server/app/app.go
+++ b/server/app/app.go
@@ -70,6 +70,14 @@ func (app App) InitDBData() (err error) {
return err
}
+ // 修复数据
+ if err := service.AssetService.FixSshMode(); err != nil {
+ return err
+ }
+ if err := service.SessionService.FixSshMode(); err != nil {
+ return err
+ }
+
return nil
}
diff --git a/server/constant/const.go b/server/constant/const.go
index eaa18d42..a07fe3e7 100644
--- a/server/constant/const.go
+++ b/server/constant/const.go
@@ -55,7 +55,7 @@ const (
Disconnected = "disconnected" // 会话状态:已断开连接
Guacd = "guacd" // 接入模式:guacd
- Naive = "naive" // 接入模式:原生
+ Native = "native" // 接入模式:原生
Terminal = "terminal" // 接入模式:终端
TypeUser = "user" // 普通用户
diff --git a/server/repository/asset.go b/server/repository/asset.go
index c77d64b9..a7d94bd9 100644
--- a/server/repository/asset.go
+++ b/server/repository/asset.go
@@ -345,3 +345,8 @@ func (r assetRepository) FindAssetAttrMapByAssetId(c context.Context, assetId st
}
return attributeMap, nil
}
+
+func (r assetRepository) UpdateAttrs(c context.Context, name, value, newValue string) error {
+ sql := "update asset_attributes set value = ? where name = ? and value = ?"
+ return r.GetDB(c).Exec(sql, newValue, name, value).Error
+}
diff --git a/server/repository/session.go b/server/repository/session.go
index 7052706f..26639b73 100644
--- a/server/repository/session.go
+++ b/server/repository/session.go
@@ -168,3 +168,8 @@ func (r sessionRepository) FindAllUnReviewed(c context.Context) (o []model.Sessi
err = r.GetDB(c).Where("reviewed = false or reviewed is null").Find(&o).Error
return
}
+
+func (r sessionRepository) UpdateMode(c context.Context) error {
+ sql := "update sessions set mode = 'native' where mode = 'naive'"
+ return r.GetDB(c).Exec(sql).Error
+}
diff --git a/server/service/asset.go b/server/service/asset.go
index a5c9f1b4..b558f5df 100644
--- a/server/service/asset.go
+++ b/server/service/asset.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"next-terminal/server/config"
+ "next-terminal/server/constant"
"next-terminal/server/env"
"next-terminal/server/model"
"next-terminal/server/repository"
@@ -260,3 +261,7 @@ func (s assetService) UpdateById(id string, m echo.Map) error {
})
}
+
+func (s assetService) FixSshMode() error {
+ return repository.AssetRepository.UpdateAttrs(context.TODO(), "ssh-mode", "naive", constant.Native)
+}
diff --git a/server/service/session.go b/server/service/session.go
index 3f91b272..c138bfc7 100644
--- a/server/service/session.go
+++ b/server/service/session.go
@@ -118,7 +118,7 @@ func (service sessionService) WriteCloseMessage(ws *websocket.Conn, mode string,
disconnect := guacd.NewInstruction("disconnect")
_ = ws.WriteMessage(websocket.TextMessage, []byte(disconnect.String()))
}
- case constant.Naive:
+ case constant.Native:
if ws != nil {
msg := `0` + reason
_ = ws.WriteMessage(websocket.TextMessage, []byte(msg))
@@ -354,3 +354,7 @@ func (service sessionService) Create(clientIp, assetId, mode string, user *model
}
return s, nil
}
+
+func (service sessionService) FixSshMode() error {
+ return repository.SessionRepository.UpdateMode(context.TODO())
+}
diff --git a/web/src/common/constants.js b/web/src/common/constants.js
index 1ef0fc74..ce1ddb58 100644
--- a/web/src/common/constants.js
+++ b/web/src/common/constants.js
@@ -8,6 +8,6 @@ export const PROTOCOL_COLORS = {
export const MODE_COLORS = {
'guacd': 'green',
- 'naive': 'orange',
+ 'native': 'orange',
'terminal': 'purple',
}
\ No newline at end of file
diff --git a/web/src/components/access/BatchCommandTerm.js b/web/src/components/access/BatchCommandTerm.js
index f3a2e2ce..0d78cb19 100644
--- a/web/src/components/access/BatchCommandTerm.js
+++ b/web/src/components/access/BatchCommandTerm.js
@@ -124,7 +124,7 @@ class BatchCommandTerm extends Component {
}
async createSession(assetsId) {
- let result = await request.post(`/sessions?assetId=${assetsId}&mode=naive`);
+ let result = await request.post(`/sessions?assetId=${assetsId}&mode=native`);
if (result['code'] !== 1) {
this.showMessage(result['message']);
return null;
diff --git a/web/src/components/access/Term.js b/web/src/components/access/Term.js
index b0f351ee..3903acd0 100644
--- a/web/src/components/access/Term.js
+++ b/web/src/components/access/Term.js
@@ -210,7 +210,7 @@ class Term extends Component {
}
async createSession(assetsId) {
- let result = await request.post(`/sessions?assetId=${assetsId}&mode=naive`);
+ let result = await request.post(`/sessions?assetId=${assetsId}&mode=native`);
if (result['code'] !== 1) {
this.showMessage(result['message']);
return undefined;
diff --git a/web/src/components/asset/Asset.js b/web/src/components/asset/Asset.js
index f1e1efdc..2918d436 100644
--- a/web/src/components/asset/Asset.js
+++ b/web/src/components/asset/Asset.js
@@ -558,7 +558,7 @@ class Asset extends Component {
const name = record['name'];
const sshMode = record['sshMode'];
let url = '';
- if (protocol === 'ssh' && sshMode === 'naive') {
+ if (protocol === 'ssh' && sshMode === 'native') {
url = `#/term?assetId=${id}&assetName=${name}`;
} else {
url = `#/access?assetId=${id}&assetName=${name}&protocol=${protocol}`;
diff --git a/web/src/components/asset/AssetModal.js b/web/src/components/asset/AssetModal.js
index 54112ec8..85cd04c4 100644
--- a/web/src/components/asset/AssetModal.js
+++ b/web/src/components/asset/AssetModal.js
@@ -456,7 +456,7 @@ Windows需要对远程应用程序的名称使用特殊的符号。
setSshMode(value)
}}>
-
+
diff --git a/web/src/components/asset/MyAsset.js b/web/src/components/asset/MyAsset.js
index 01ddd05a..73a52ddc 100644
--- a/web/src/components/asset/MyAsset.js
+++ b/web/src/components/asset/MyAsset.js
@@ -280,7 +280,7 @@ class MyAsset extends Component {
const name = item['name'];
const sshMode = item['sshMode'];
let url = '';
- if (protocol === 'ssh' && sshMode === 'naive') {
+ if (protocol === 'ssh' && sshMode === 'native') {
url = `#/term?assetId=${id}&assetName=${name}`;
} else {
url = `#/access?assetId=${id}&assetName=${name}&protocol=${protocol}`;
diff --git a/web/src/components/session/OfflineSession.js b/web/src/components/session/OfflineSession.js
index 581a6667..a438ca56 100644
--- a/web/src/components/session/OfflineSession.js
+++ b/web/src/components/session/OfflineSession.js
@@ -654,7 +654,7 @@ class OfflineSession extends Component {
maskClosable={false}
>
{
- this.state.selectedRow['mode'] === 'naive' || this.state.selectedRow['mode'] === 'terminal' ?
+ this.state.selectedRow['mode'] === 'native' || this.state.selectedRow['mode'] === 'terminal' ?