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
6370e59c
Commit
6370e59c
authored
May 10, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] interactive choose systemuser
parent
42b78fa9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
session.go
pkg/handler/session.go
+6
-6
srvconn.go
pkg/proxy/srvconn.go
+0
-1
No files found.
pkg/handler/session.go
View file @
6370e59c
...
@@ -162,18 +162,19 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
...
@@ -162,18 +162,19 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
highestPriority
:=
systemUsers
[
length
-
1
]
.
Priority
highestPriority
:=
systemUsers
[
length
-
1
]
.
Priority
displaySystemUsers
=
append
(
displaySystemUsers
,
systemUsers
[
length
-
1
])
displaySystemUsers
=
append
(
displaySystemUsers
,
systemUsers
[
length
-
1
])
for
i
:=
length
-
2
;
i
<
=
0
;
i
--
{
for
i
:=
length
-
2
;
i
>
=
0
;
i
--
{
if
highestPriority
==
systemUsers
[
i
]
.
Priority
{
if
highestPriority
==
systemUsers
[
i
]
.
Priority
{
displaySystemUsers
=
append
(
displaySystemUsers
,
systemUsers
[
length
-
1
])
displaySystemUsers
=
append
(
displaySystemUsers
,
systemUsers
[
i
])
}
}
}
}
if
len
(
displaySystemUsers
)
==
1
{
if
len
(
displaySystemUsers
)
==
1
{
return
displaySystemUsers
[
0
]
return
displaySystemUsers
[
0
]
}
}
table
:=
tablewriter
.
NewWriter
(
h
.
term
)
table
:=
tablewriter
.
NewWriter
(
h
.
term
)
table
.
SetHeader
([]
string
{
"ID"
,
"Username"
})
table
.
SetHeader
([]
string
{
"ID"
,
"Username"
})
for
i
:=
0
;
i
<
len
(
displaySystemUsers
);
i
++
{
for
i
:=
0
;
i
<
len
(
displaySystemUsers
);
i
++
{
table
.
Append
([]
string
{
strconv
.
Itoa
(
i
+
1
),
s
ystemUsers
[
i
]
.
Username
})
table
.
Append
([]
string
{
strconv
.
Itoa
(
i
+
1
),
displayS
ystemUsers
[
i
]
.
Username
})
}
}
table
.
SetBorder
(
false
)
table
.
SetBorder
(
false
)
count
:=
0
count
:=
0
...
@@ -185,8 +186,8 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
...
@@ -185,8 +186,8 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
continue
continue
}
}
if
num
,
err
:=
strconv
.
Atoi
(
line
);
err
==
nil
{
if
num
,
err
:=
strconv
.
Atoi
(
line
);
err
==
nil
{
if
num
>
0
&&
num
<=
len
(
s
ystemUsers
)
{
if
num
>
0
&&
num
<=
len
(
displayS
ystemUsers
)
{
return
s
ystemUsers
[
num
-
1
]
return
displayS
ystemUsers
[
num
-
1
]
}
}
}
}
count
++
count
++
...
@@ -197,7 +198,6 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
...
@@ -197,7 +198,6 @@ func (h *interactiveHandler) chooseSystemUser(systemUsers []model.SystemUser) mo
// 当资产的数量为1的时候,就进行代理转化
// 当资产的数量为1的时候,就进行代理转化
func
(
h
*
interactiveHandler
)
displayAssetsOrProxy
(
assets
[]
model
.
Asset
)
{
func
(
h
*
interactiveHandler
)
displayAssetsOrProxy
(
assets
[]
model
.
Asset
)
{
if
len
(
assets
)
==
1
{
if
len
(
assets
)
==
1
{
logger
.
Debug
(
assets
[
0
]
.
SystemUsers
)
systemUser
:=
h
.
chooseSystemUser
(
assets
[
0
]
.
SystemUsers
)
systemUser
:=
h
.
chooseSystemUser
(
assets
[
0
]
.
SystemUsers
)
h
.
assetSelect
=
&
assets
[
0
]
h
.
assetSelect
=
&
assets
[
0
]
h
.
systemUserSelect
=
&
systemUser
h
.
systemUserSelect
=
&
systemUser
...
...
pkg/proxy/srvconn.go
View file @
6370e59c
...
@@ -158,7 +158,6 @@ func (sc *ServerSSHConnection) invokeShell(h, w int, term string) (err error) {
...
@@ -158,7 +158,6 @@ func (sc *ServerSSHConnection) invokeShell(h, w int, term string) (err error) {
func
(
sc
*
ServerSSHConnection
)
Connect
(
h
,
w
int
,
term
string
)
(
err
error
)
{
func
(
sc
*
ServerSSHConnection
)
Connect
(
h
,
w
int
,
term
string
)
(
err
error
)
{
_
,
err
=
sc
.
connect
()
_
,
err
=
sc
.
connect
()
fmt
.
Println
(
"error"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
...
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