Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
4c1125a8
Unverified
Commit
4c1125a8
authored
Oct 25, 2019
by
Eric_Lee
Committed by
GitHub
Oct 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dev i18n (#118)
[Update] i18n info
parent
79010965
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
126 deletions
+120
-126
koko.po
cmd/locale/en_US/LC_MESSAGES/koko.po
+39
-49
koko.mo
cmd/locale/zh_CN/LC_MESSAGES/koko.mo
+0
-0
koko.po
cmd/locale/zh_CN/LC_MESSAGES/koko.po
+41
-50
banner.go
pkg/handler/banner.go
+23
-0
pagination.go
pkg/handler/pagination.go
+11
-16
session.go
pkg/handler/session.go
+4
-8
proxy.go
pkg/proxy/proxy.go
+2
-3
No files found.
cmd/locale/en_US/LC_MESSAGES/koko.po
View file @
4c1125a8
...
@@ -8,171 +8,161 @@ msgstr ""
...
@@ -8,171 +8,161 @@ msgstr ""
"X-Generator: xgotext\n"
"X-Generator: xgotext\n"
#. i18n.T
#. i18n.T
#: pkg/auth/server.go:17
#: pkg/handler/banner.go:31
msgid "Please enter 6 digits."
msgstr ""
#. i18n.T
#: pkg/auth/server.go:18
msgid "[MFA auth]: "
msgstr ""
#. i18n.T
#: pkg/handler/banner.go:32
msgid "\t%d) Enter {{.GreenBoldColor}}%s{{.ColorEnd}} to %s.%s"
msgid "\t%d) Enter {{.GreenBoldColor}}%s{{.ColorEnd}} to %s.%s"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:4
7
#: pkg/handler/banner.go:4
6
msgid "Welcome to use Jumpserver open source fortress system"
msgid "Welcome to use Jumpserver open source fortress system"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:4
9
#: pkg/handler/banner.go:4
8
msgid "directly login"
msgid "directly login"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:
50
#: pkg/handler/banner.go:
49
msgid "part IP, Hostname, Comment"
msgid "part IP, Hostname, Comment"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:
50
#: pkg/handler/banner.go:
49
msgid "to search login if unique"
msgid "to search login if unique"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
1
#: pkg/handler/banner.go:5
0
msgid "/ + IP, Hostname, Comment"
msgid "/ + IP, Hostname, Comment"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
1
#: pkg/handler/banner.go:5
0
msgid "to search, such as: /192.168"
msgid "to search, such as: /192.168"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
2
#: pkg/handler/banner.go:5
1
msgid "display the host you have permission"
msgid "display the host you have permission"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
3
#: pkg/handler/banner.go:5
2
msgid "display the node that you have permission"
msgid "display the node that you have permission"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
4
#: pkg/handler/banner.go:5
3
msgid "refresh your assets and nodes"
msgid "refresh your assets and nodes"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
5
#: pkg/handler/banner.go:5
4
msgid "print help"
msgid "print help"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
6
#: pkg/handler/banner.go:5
5
msgid "exit"
msgid "exit"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:90
msgid "ID"
msgid "ID"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:91
msgid "hostname"
msgid "hostname"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:92
msgid "IP"
msgid "IP"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:13
3
#: pkg/handler/
banner.go:9
3
msgid "
systemUsers
"
msgid "
comment
"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:94
msgid "
comment
"
msgid "
Page: %d, Count: %d, Total Page: %d, Total Count: %d
"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:152
#: pkg/handler/
banner.go:95
msgid "
Page: %d, Count: %d, Total Page: %d, Total Count: %d
"
msgid "
No Assets
"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:179
#: pkg/handler/
banner.go:96
msgid ""
msgid ""
"\n"
"\n"
"Tips: Enter the asset ID and
log directly into
the asset.\n"
"Tips: Enter the asset ID and
directly login
the asset.\n"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:180
#: pkg/handler/
banner.go:97
msgid ""
msgid ""
"\n"
"\n"
"Page up: P/p\tPage down: Enter|N/n\tBACK: b.\n"
"Page up: P/p\tPage down: Enter|N/n\tBACK: b.\n"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/session.go:267
#: pkg/handler/banner.go:98
msgid "No Assets"
msgstr ""
#. i18n.T
#: pkg/handler/session.go:289
msgid "Node: [ ID.Name(Asset amount) ]"
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
session.go:290
#: pkg/handler/
banner.go:99
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/handler/
session.go:304
#: pkg/handler/
banner.go:100
msgid "Refresh done"
msgid "Refresh done"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/parser.go:1
24
#: pkg/proxy/parser.go:1
31
msgid "Command `%s` is forbidden"
msgid "Command `%s` is forbidden"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/proxy.go:152
#: pkg/proxy/proxy.go:143
msgid "Reuse SSH connections (%s@%s) [Number of connections: %d]"
msgstr ""
#. i18n.T
#: pkg/proxy/proxy.go:161
msgid "Connecting to %s@%s %.1f"
msgid "Connecting to %s@%s %.1f"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/proxy.go:1
71
#: pkg/proxy/proxy.go:1
80
msgid "System user <%s> and asset <%s> protocol are inconsistent."
msgid "System user <%s> and asset <%s> protocol are inconsistent."
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/proxy.go:1
77
#: pkg/proxy/proxy.go:1
86
msgid ""
msgid ""
"Terminal only support protocol ssh/telnet, please use web terminal to access"
"Terminal only support protocol ssh/telnet, please use web terminal to access"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/sessmanager.go:6
3
#: pkg/proxy/sessmanager.go:6
7
msgid "Connect with api server failed"
msgid "Connect with api server failed"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/switch.go:1
42
#: pkg/proxy/switch.go:1
59
msgid "Connect idle more than %d minutes, disconnect"
msgid "Connect idle more than %d minutes, disconnect"
msgstr ""
msgstr ""
#. i18n.T
#. i18n.T
#: pkg/proxy/switch.go:1
48
#: pkg/proxy/switch.go:1
66
msgid "Terminated by administrator"
msgid "Terminated by administrator"
msgstr ""
msgstr ""
cmd/locale/zh_CN/LC_MESSAGES/koko.mo
View file @
4c1125a8
No preview for this file type
cmd/locale/zh_CN/LC_MESSAGES/koko.po
View file @
4c1125a8
...
@@ -8,116 +8,107 @@ msgstr ""
...
@@ -8,116 +8,107 @@ msgstr ""
"X-Generator: xgotext\n"
"X-Generator: xgotext\n"
#. i18n.T
#. i18n.T
#: pkg/auth/server.go:17
#: pkg/handler/banner.go:31
msgid "Please enter 6 digits."
msgstr "请输入六位数字"
#. i18n.T
#: pkg/auth/server.go:18
msgid "[MFA auth]: "
msgstr "[MFA认证]"
#. i18n.T
#: pkg/handler/banner.go:32
msgid "\t%d) Enter {{.GreenBoldColor}}%s{{.ColorEnd}} to %s.%s"
msgid "\t%d) Enter {{.GreenBoldColor}}%s{{.ColorEnd}} to %s.%s"
msgstr "\t%d) 输入 {{.GreenBoldColor}}%s{{.ColorEnd}} 进行%s.%s"
msgstr "\t%d) 输入 {{.GreenBoldColor}}%s{{.ColorEnd}} 进行%s.%s"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:4
7
#: pkg/handler/banner.go:4
6
msgid "Welcome to use Jumpserver open source fortress system"
msgid "Welcome to use Jumpserver open source fortress system"
msgstr "欢迎使用Jumpserver开源堡垒机系统"
msgstr "欢迎使用Jumpserver开源堡垒机系统"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:4
9
#: pkg/handler/banner.go:4
8
msgid "directly login"
msgid "directly login"
msgstr "直接登陆"
msgstr "直接登陆"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:
50
#: pkg/handler/banner.go:
49
msgid "part IP, Hostname, Comment"
msgid "part IP, Hostname, Comment"
msgstr "部分IP、主机名、备注"
msgstr "部分IP、主机名、备注"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:
50
#: pkg/handler/banner.go:
49
msgid "to search login if unique"
msgid "to search login if unique"
msgstr "进行搜索登录(如果唯一)"
msgstr "进行搜索登录(如果唯一)"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
1
#: pkg/handler/banner.go:5
0
msgid "/ + IP, Hostname, Comment"
msgid "/ + IP, Hostname, Comment"
msgstr "/ + IP, 主机名 or 备注"
msgstr "/ + IP, 主机名 or 备注"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
1
#: pkg/handler/banner.go:5
0
msgid "to search, such as: /192.168"
msgid "to search, such as: /192.168"
msgstr "搜索, 如: /192.168"
msgstr "搜索, 如: /192.168"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
2
#: pkg/handler/banner.go:5
1
msgid "display the host you have permission"
msgid "display the host you have permission"
msgstr "显示您有权限的主机"
msgstr "显示您有权限的主机"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
3
#: pkg/handler/banner.go:5
2
msgid "display the node that you have permission"
msgid "display the node that you have permission"
msgstr "显示您有权限的节点"
msgstr "显示您有权限的节点"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
4
#: pkg/handler/banner.go:5
3
msgid "refresh your assets and nodes"
msgid "refresh your assets and nodes"
msgstr "刷新最新的机器和节点信息"
msgstr "刷新最新的机器和节点信息"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
5
#: pkg/handler/banner.go:5
4
msgid "print help"
msgid "print help"
msgstr "显示帮助"
msgstr "显示帮助"
#. i18n.T
#. i18n.T
#: pkg/handler/banner.go:5
6
#: pkg/handler/banner.go:5
5
msgid "exit"
msgid "exit"
msgstr "退出"
msgstr "退出"
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:90
msgid "ID"
msgid "ID"
msgstr "ID"
msgstr "ID"
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:91
msgid "hostname"
msgid "hostname"
msgstr "主机名"
msgstr "主机名"
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:133
#: pkg/handler/
banner.go:92
msgid "IP"
msgid "IP"
msgstr "IP"
msgstr "IP"
#. i18n.T
#. i18n.T
#: pkg/handler/pagination.go:133
#: pkg/handler/banner.go:93
msgid "systemUsers"
msgstr "登录用户"
#. i18n.T
#: pkg/handler/pagination.go:133
msgid "comment"
msgid "comment"
msgstr "备注"
msgstr "备注"
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:152
#: pkg/handler/
banner.go:94
msgid "Page: %d, Count: %d, Total Page: %d, Total Count: %d"
msgid "Page: %d, Count: %d, Total Page: %d, Total Count: %d"
msgstr "页码: %d, 每页行数: %d, 总页数: %d, 总数量: %d"
msgstr "页码: %d, 每页行数: %d, 总页数: %d, 总数量: %d"
#. i18n.T
#. i18n.T
#: pkg/handler/pagination.go:179
#: pkg/handler/banner.go:95
msgid "No Assets"
msgstr "没有资产"
#. i18n.T
#: pkg/handler/banner.go:96
#, fuzzy
msgid ""
msgid ""
"\n"
"\n"
"Tips: Enter the asset ID and
log directly into
the asset.\n"
"Tips: Enter the asset ID and
directly login
the asset.\n"
msgstr ""
msgstr ""
"\n"
"\n"
"提示: 输入资产ID,直接登录资产.\n"
"提示: 输入资产ID,直接登录资产.\n"
#. i18n.T
#. i18n.T
#: pkg/handler/
pagination.go:180
#: pkg/handler/
banner.go:97
msgid ""
msgid ""
"\n"
"\n"
"Page up: P/p\tPage down: Enter|N/n\tBACK: b.\n"
"Page up: P/p\tPage down: Enter|N/n\tBACK: b.\n"
...
@@ -126,57 +117,57 @@ msgstr ""
...
@@ -126,57 +117,57 @@ msgstr ""
"上一页: P/p 下一页: Enter|N/n 返回: B/b\n"
"上一页: P/p 下一页: Enter|N/n 返回: B/b\n"
#. i18n.T
#. i18n.T
#: pkg/handler/session.go:267
#: pkg/handler/banner.go:98
msgid "No Assets"
msgstr "没有资产"
#. i18n.T
#: pkg/handler/session.go:289
msgid "Node: [ ID.Name(Asset amount) ]"
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr "节点: [ ID.名称(资产数量) ]"
msgstr "节点: [ ID.名称(资产数量) ]"
#. i18n.T
#. i18n.T
#: pkg/handler/
session.go:290
#: pkg/handler/
banner.go:99
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgstr "提示: 输入 g+节点ID 显示节点下主机. 如: g1"
msgstr "提示: 输入 g+节点ID 显示节点下主机. 如: g1"
#. i18n.T
#. i18n.T
#: pkg/handler/
session.go:304
#: pkg/handler/
banner.go:100
msgid "Refresh done"
msgid "Refresh done"
msgstr "刷新完成"
msgstr "刷新完成"
#. i18n.T
#. i18n.T
#: pkg/proxy/parser.go:1
24
#: pkg/proxy/parser.go:1
31
msgid "Command `%s` is forbidden"
msgid "Command `%s` is forbidden"
msgstr "命令 `%s` 是被禁止的 ..."
msgstr "命令 `%s` 是被禁止的 ..."
#. i18n.T
#. i18n.T
#: pkg/proxy/proxy.go:152
#: pkg/proxy/proxy.go:143
msgid "Reuse SSH connections (%s@%s) [Number of connections: %d]"
msgstr "复用SSH连接(%s@%s)[连接数量: %d]"
#. i18n.T
#: pkg/proxy/proxy.go:161
msgid "Connecting to %s@%s %.1f"
msgid "Connecting to %s@%s %.1f"
msgstr "开始连接到 %s@%s %.1f"
msgstr "开始连接到 %s@%s %.1f"
#. i18n.T
#. i18n.T
#: pkg/proxy/proxy.go:1
71
#: pkg/proxy/proxy.go:1
80
msgid "System user <%s> and asset <%s> protocol are inconsistent."
msgid "System user <%s> and asset <%s> protocol are inconsistent."
msgstr "系统用户<%s>和资产<%s>协议不一致"
msgstr "系统用户<%s>和资产<%s>协议不一致"
#. i18n.T
#. i18n.T
#: pkg/proxy/proxy.go:1
77
#: pkg/proxy/proxy.go:1
86
msgid ""
msgid ""
"Terminal only support protocol ssh/telnet, please use web terminal to access"
"Terminal only support protocol ssh/telnet, please use web terminal to access"
msgstr "终端仅支持ssh/telnet协议,请使用web终端登录"
msgstr "终端仅支持ssh/telnet协议,请使用web终端登录"
#. i18n.T
#. i18n.T
#: pkg/proxy/sessmanager.go:6
3
#: pkg/proxy/sessmanager.go:6
7
msgid "Connect with api server failed"
msgid "Connect with api server failed"
msgstr "连接API服务失败"
msgstr "连接API服务失败"
#. i18n.T
#. i18n.T
#: pkg/proxy/switch.go:1
42
#: pkg/proxy/switch.go:1
59
msgid "Connect idle more than %d minutes, disconnect"
msgid "Connect idle more than %d minutes, disconnect"
msgstr "空闲时间超过%d分钟,断开连接"
msgstr "空闲时间超过%d分钟,断开连接"
#. i18n.T
#. i18n.T
#: pkg/proxy/switch.go:1
48
#: pkg/proxy/switch.go:1
66
msgid "Terminated by administrator"
msgid "Terminated by administrator"
msgstr "管理员中断连接"
msgstr "管理员中断连接"
pkg/handler/banner.go
View file @
4c1125a8
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"bytes"
"bytes"
"fmt"
"fmt"
"io"
"io"
"sync"
"text/template"
"text/template"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/config"
...
@@ -79,3 +80,25 @@ func displayBanner(sess io.ReadWriter, user string) {
...
@@ -79,3 +80,25 @@ func displayBanner(sess io.ReadWriter, user string) {
utils
.
IgnoreErrWriteString
(
sess
,
v
.
Text
())
utils
.
IgnoreErrWriteString
(
sess
,
v
.
Text
())
}
}
}
}
var
i18nMap
map
[
string
]
string
var
i18nOnce
sync
.
Once
func
getI18nFromMap
(
name
string
)
string
{
i18nOnce
.
Do
(
func
()
{
i18nMap
=
map
[
string
]
string
{
"ID"
:
i18n
.
T
(
"ID"
),
"Hostname"
:
i18n
.
T
(
"hostname"
),
"IP"
:
i18n
.
T
(
"IP"
),
"Comment"
:
i18n
.
T
(
"comment"
),
"AssetTableCaption"
:
i18n
.
T
(
"Page: %d, Count: %d, Total Page: %d, Total Count: %d"
),
"NoAssets"
:
i18n
.
T
(
"No Assets"
),
"LoginTip"
:
i18n
.
T
(
"
\n
Tips: Enter the asset ID and directly login the asset.
\n
"
),
"PageActionTip"
:
i18n
.
T
(
"
\n
Page up: P/p Page down: Enter|N/n BACK: b.
\n
"
),
"NodeHeaderTip"
:
i18n
.
T
(
"Node: [ ID.Name(Asset amount) ]"
),
"NodeEndTip"
:
i18n
.
T
(
"Tips: Enter g+NodeID to display the host under the node, such as g1"
),
"RefreshDone"
:
i18n
.
T
(
"Refresh done"
),
}
})
return
i18nMap
[
name
]
}
pkg/handler/pagination.go
View file @
4c1125a8
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"github.com/jumpserver/koko/pkg/common"
"github.com/jumpserver/koko/pkg/common"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/i18n"
"github.com/jumpserver/koko/pkg/model"
"github.com/jumpserver/koko/pkg/model"
"github.com/jumpserver/koko/pkg/service"
"github.com/jumpserver/koko/pkg/service"
"github.com/jumpserver/koko/pkg/utils"
"github.com/jumpserver/koko/pkg/utils"
...
@@ -132,7 +131,8 @@ func (p *AssetPagination) Start() []model.Asset {
...
@@ -132,7 +131,8 @@ func (p *AssetPagination) Start() []model.Asset {
}
}
func
(
p
*
AssetPagination
)
displayPageAssets
()
{
func
(
p
*
AssetPagination
)
displayPageAssets
()
{
Labels
:=
[]
string
{
i18n
.
T
(
"ID"
),
i18n
.
T
(
"hostname"
),
i18n
.
T
(
"IP"
),
i18n
.
T
(
"comment"
)}
Labels
:=
[]
string
{
getI18nFromMap
(
"ID"
),
getI18nFromMap
(
"Hostname"
),
getI18nFromMap
(
"IP"
),
getI18nFromMap
(
"Comment"
)}
fields
:=
[]
string
{
"ID"
,
"hostname"
,
"IP"
,
"comment"
}
fields
:=
[]
string
{
"ID"
,
"hostname"
,
"IP"
,
"comment"
}
data
:=
make
([]
map
[
string
]
string
,
len
(
p
.
currentData
))
data
:=
make
([]
map
[
string
]
string
,
len
(
p
.
currentData
))
for
i
,
j
:=
range
p
.
currentData
{
for
i
,
j
:=
range
p
.
currentData
{
...
@@ -152,7 +152,7 @@ func (p *AssetPagination) displayPageAssets() {
...
@@ -152,7 +152,7 @@ func (p *AssetPagination) displayPageAssets() {
data
[
i
]
=
row
data
[
i
]
=
row
}
}
w
,
_
:=
p
.
term
.
GetSize
()
w
,
_
:=
p
.
term
.
GetSize
()
caption
:=
fmt
.
Sprintf
(
i18n
.
T
(
"Page: %d, Count: %d, Total Page: %d, Total Count: %d
"
),
caption
:=
fmt
.
Sprintf
(
getI18nFromMap
(
"AssetTableCaption
"
),
p
.
page
.
CurrentPage
(),
p
.
page
.
PageSize
(),
p
.
page
.
TotalPage
(),
p
.
page
.
TotalCount
(),
p
.
page
.
CurrentPage
(),
p
.
page
.
PageSize
(),
p
.
page
.
TotalPage
(),
p
.
page
.
TotalCount
(),
)
)
caption
=
utils
.
WrapperString
(
caption
,
utils
.
Green
)
caption
=
utils
.
WrapperString
(
caption
,
utils
.
Green
)
...
@@ -269,12 +269,12 @@ func (p *UserAssetPagination) Start() []model.Asset {
...
@@ -269,12 +269,12 @@ func (p *UserAssetPagination) Start() []model.Asset {
func
(
p
*
UserAssetPagination
)
displayPageAssets
()
{
func
(
p
*
UserAssetPagination
)
displayPageAssets
()
{
if
len
(
p
.
Data
.
Data
)
==
0
{
if
len
(
p
.
Data
.
Data
)
==
0
{
_
,
_
=
p
.
term
.
Write
([]
byte
(
i18n
.
T
(
"No Assets"
)))
_
,
_
=
p
.
term
.
Write
([]
byte
(
getI18nFromMap
(
"NoAssets"
)
+
"
\n\r
"
))
_
,
_
=
p
.
term
.
Write
([]
byte
(
"
\n\r
"
))
return
return
}
}
Labels
:=
[]
string
{
i18n
.
T
(
"ID"
),
i18n
.
T
(
"hostname"
),
i18n
.
T
(
"IP"
),
i18n
.
T
(
"comment"
)}
Labels
:=
[]
string
{
getI18nFromMap
(
"ID"
),
getI18nFromMap
(
"Hostname"
),
getI18nFromMap
(
"IP"
),
getI18nFromMap
(
"Comment"
)}
fields
:=
[]
string
{
"ID"
,
"hostname"
,
"IP"
,
"comment"
}
fields
:=
[]
string
{
"ID"
,
"hostname"
,
"IP"
,
"comment"
}
p
.
currentData
=
model
.
AssetList
(
p
.
Data
.
Data
)
.
SortBy
(
config
.
GetConf
()
.
AssetListSortBy
)
p
.
currentData
=
model
.
AssetList
(
p
.
Data
.
Data
)
.
SortBy
(
config
.
GetConf
()
.
AssetListSortBy
)
data
:=
make
([]
map
[
string
]
string
,
len
(
p
.
currentData
))
data
:=
make
([]
map
[
string
]
string
,
len
(
p
.
currentData
))
...
@@ -324,9 +324,9 @@ func (p *UserAssetPagination) displayPageAssets() {
...
@@ -324,9 +324,9 @@ func (p *UserAssetPagination) displayPageAssets() {
currentPage
=
(
currentOffset
/
pageSize
)
+
1
currentPage
=
(
currentOffset
/
pageSize
)
+
1
}
}
}
}
caption
:=
fmt
.
Sprintf
(
i18n
.
T
(
"Page: %d, Count: %d, Total Page: %d, Total Count: %d
"
),
caption
:=
fmt
.
Sprintf
(
getI18nFromMap
(
"AssetTableCaption
"
),
currentPage
,
pageSize
,
totalPage
,
totalCount
,
currentPage
,
pageSize
,
totalPage
,
totalCount
)
)
caption
=
utils
.
WrapperString
(
caption
,
utils
.
Green
)
caption
=
utils
.
WrapperString
(
caption
,
utils
.
Green
)
table
:=
common
.
WrapperTable
{
table
:=
common
.
WrapperTable
{
Fields
:
fields
,
Fields
:
fields
,
...
@@ -387,11 +387,6 @@ func getPageSize(term *utils.Terminal) int {
...
@@ -387,11 +387,6 @@ func getPageSize(term *utils.Terminal) int {
}
}
func
displayAssetPaginationTipsInfo
(
w
io
.
Writer
)
{
func
displayAssetPaginationTipsInfo
(
w
io
.
Writer
)
{
tips
:=
[]
string
{
utils
.
IgnoreErrWriteString
(
w
,
getI18nFromMap
(
"LoginTip"
))
i18n
.
T
(
"
\n
Tips: Enter the asset ID and log directly into the asset.
\n
"
),
utils
.
IgnoreErrWriteString
(
w
,
getI18nFromMap
(
"PageActionTip"
))
i18n
.
T
(
"
\n
Page up: P/p Page down: Enter|N/n BACK: b.
\n
"
),
}
for
_
,
tip
:=
range
tips
{
_
,
_
=
w
.
Write
([]
byte
(
tip
))
}
}
}
pkg/handler/session.go
View file @
4c1125a8
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"github.com/jumpserver/koko/pkg/cctx"
"github.com/jumpserver/koko/pkg/cctx"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/i18n"
"github.com/jumpserver/koko/pkg/logger"
"github.com/jumpserver/koko/pkg/logger"
"github.com/jumpserver/koko/pkg/model"
"github.com/jumpserver/koko/pkg/model"
"github.com/jumpserver/koko/pkg/proxy"
"github.com/jumpserver/koko/pkg/proxy"
...
@@ -239,7 +238,7 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
...
@@ -239,7 +238,7 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
func
(
h
*
interactiveHandler
)
displayAssets
(
assets
model
.
AssetList
)
{
func
(
h
*
interactiveHandler
)
displayAssets
(
assets
model
.
AssetList
)
{
if
len
(
assets
)
==
0
{
if
len
(
assets
)
==
0
{
_
,
_
=
io
.
WriteString
(
h
.
term
,
i18n
.
T
(
"No
Assets"
)
+
"
\n\r
"
)
_
,
_
=
io
.
WriteString
(
h
.
term
,
getI18nFromMap
(
"No
Assets"
)
+
"
\n\r
"
)
}
else
{
}
else
{
sortedAssets
:=
assets
.
SortBy
(
config
.
GetConf
()
.
AssetListSortBy
)
sortedAssets
:=
assets
.
SortBy
(
config
.
GetConf
()
.
AssetListSortBy
)
pag
:=
NewAssetPagination
(
h
.
term
,
sortedAssets
)
pag
:=
NewAssetPagination
(
h
.
term
,
sortedAssets
)
...
@@ -259,12 +258,9 @@ func (h *interactiveHandler) displayAssets(assets model.AssetList) {
...
@@ -259,12 +258,9 @@ func (h *interactiveHandler) displayAssets(assets model.AssetList) {
func
(
h
*
interactiveHandler
)
displayNodes
(
nodes
[]
model
.
Node
)
{
func
(
h
*
interactiveHandler
)
displayNodes
(
nodes
[]
model
.
Node
)
{
tree
:=
ConstructAssetNodeTree
(
nodes
)
tree
:=
ConstructAssetNodeTree
(
nodes
)
tipHeaderMsg
:=
i18n
.
T
(
"Node: [ ID.Name(Asset amount) ]"
)
_
,
err
:=
io
.
WriteString
(
h
.
term
,
"
\n\r
"
+
getI18nFromMap
(
"NodeHeaderTip"
))
tipEndMsg
:=
i18n
.
T
(
"Tips: Enter g+NodeID to display the host under the node, such as g1"
)
_
,
err
:=
io
.
WriteString
(
h
.
term
,
"
\n\r
"
+
tipHeaderMsg
)
_
,
err
=
io
.
WriteString
(
h
.
term
,
tree
.
String
())
_
,
err
=
io
.
WriteString
(
h
.
term
,
tree
.
String
())
_
,
err
=
io
.
WriteString
(
h
.
term
,
tipEndMsg
+
"
\n\r
"
)
_
,
err
=
io
.
WriteString
(
h
.
term
,
getI18nFromMap
(
"NodeEndTip"
)
+
"
\n\r
"
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Info
(
"displayAssetNodes err:"
,
err
)
logger
.
Info
(
"displayAssetNodes err:"
,
err
)
}
}
...
@@ -277,7 +273,7 @@ func (h *interactiveHandler) refreshAssetsAndNodesData() {
...
@@ -277,7 +273,7 @@ func (h *interactiveHandler) refreshAssetsAndNodesData() {
h
.
loadAllAssets
()
h
.
loadAllAssets
()
}
}
h
.
loadUserNodes
(
"2"
)
h
.
loadUserNodes
(
"2"
)
_
,
err
:=
io
.
WriteString
(
h
.
term
,
i18n
.
T
(
"Refresh d
one"
)
+
"
\n\r
"
)
_
,
err
:=
io
.
WriteString
(
h
.
term
,
getI18nFromMap
(
"RefreshD
one"
)
+
"
\n\r
"
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"refresh Assets Nodes err:"
,
err
)
logger
.
Error
(
"refresh Assets Nodes err:"
,
err
)
}
}
...
...
pkg/proxy/proxy.go
View file @
4c1125a8
...
@@ -140,11 +140,10 @@ func (p *ProxyServer) getServerConn() (srvConn srvconn.ServerConnection, err err
...
@@ -140,11 +140,10 @@ func (p *ProxyServer) getServerConn() (srvConn srvconn.ServerConnection, err err
}()
}()
go
p
.
sendConnectingMsg
(
done
,
config
.
GetConf
()
.
SSHTimeout
*
time
.
Second
)
go
p
.
sendConnectingMsg
(
done
,
config
.
GetConf
()
.
SSHTimeout
*
time
.
Second
)
}
else
{
}
else
{
reuseMsg
:=
fmt
.
Sprintf
(
"You reuse SSH client (%s@%s) [current reuse count: %d]"
,
reuseMsg
:=
fmt
.
Sprintf
(
i18n
.
T
(
"Reuse SSH connections (%s@%s) [Number of connections: %d]"
)
,
p
.
SystemUser
.
Username
,
p
.
Asset
.
Hostname
,
p
.
cacheSSHClient
.
RefCount
())
p
.
SystemUser
.
Username
,
p
.
Asset
.
Hostname
,
p
.
cacheSSHClient
.
RefCount
())
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
utils
.
WrapperString
(
"Please notice:
\r\n
"
,
utils
.
Green
))
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
reuseMsg
+
"
\r\n
"
)
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
utils
.
WrapperString
(
reuseMsg
+
"
\r\n
"
,
utils
.
Green
))
logger
.
Infof
(
"Request %s: Reuse connection for SSH. SSH client %p current ref: %d"
,
p
.
UserConn
.
ID
(),
logger
.
Infof
(
"Request %s: Reuse connection for SSH. SSH client %p current ref: %d"
,
p
.
UserConn
.
ID
(),
p
.
cacheSSHClient
,
p
.
cacheSSHClient
.
RefCount
())
p
.
cacheSSHClient
,
p
.
cacheSSHClient
.
RefCount
())
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment