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
8384899f
Commit
8384899f
authored
Oct 24, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] manual input systemuser err
parent
2411936c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
proxy.go
pkg/proxy/proxy.go
+18
-9
No files found.
pkg/proxy/proxy.go
View file @
8384899f
...
@@ -129,14 +129,6 @@ func (p *ProxyServer) getTelnetConn() (srvConn *srvconn.ServerTelnetConnection,
...
@@ -129,14 +129,6 @@ func (p *ProxyServer) getTelnetConn() (srvConn *srvconn.ServerTelnetConnection,
// getServerConn 获取获取server连接
// getServerConn 获取获取server连接
func
(
p
*
ProxyServer
)
getServerConn
()
(
srvConn
srvconn
.
ServerConnection
,
err
error
)
{
func
(
p
*
ProxyServer
)
getServerConn
()
(
srvConn
srvconn
.
ServerConnection
,
err
error
)
{
err
=
p
.
getSystemUserUsernameIfNeed
()
if
err
!=
nil
{
return
}
err
=
p
.
getSystemUserAuthOrManualSet
()
if
err
!=
nil
{
return
}
done
:=
make
(
chan
struct
{})
done
:=
make
(
chan
struct
{})
defer
func
()
{
defer
func
()
{
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
"
\r\n
"
)
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
"
\r\n
"
)
...
@@ -188,9 +180,26 @@ func (p *ProxyServer) preCheckRequisite() (ok bool) {
...
@@ -188,9 +180,26 @@ func (p *ProxyServer) preCheckRequisite() (ok bool) {
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
msg
)
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
msg
)
return
return
}
}
if
err
:=
p
.
checkRequiredSystemUserInfo
();
err
!=
nil
{
msg
:=
fmt
.
Sprintf
(
"You get asset %s systemuser info err: %s"
,
p
.
Asset
.
Hostname
,
err
)
utils
.
IgnoreErrWriteString
(
p
.
UserConn
,
msg
)
return
}
return
true
return
true
}
}
func
(
p
*
ProxyServer
)
checkRequiredSystemUserInfo
()
error
{
if
err
:=
p
.
getSystemUserUsernameIfNeed
();
err
!=
nil
{
logger
.
Errorf
(
"Get asset %s systemuser username err: %s"
,
p
.
Asset
.
Hostname
,
err
)
return
err
}
if
err
:=
p
.
getSystemUserAuthOrManualSet
();
err
!=
nil
{
logger
.
Errorf
(
"Get asset %s systemuser password/PrivateKey err: %s"
,
p
.
Asset
.
Hostname
,
err
)
return
err
}
return
nil
}
// sendConnectErrorMsg 发送连接错误消息
// sendConnectErrorMsg 发送连接错误消息
func
(
p
*
ProxyServer
)
sendConnectErrorMsg
(
err
error
)
{
func
(
p
*
ProxyServer
)
sendConnectErrorMsg
(
err
error
)
{
msg
:=
fmt
.
Sprintf
(
"Connect asset %s error: %s
\r\n
"
,
p
.
Asset
.
Hostname
,
err
)
msg
:=
fmt
.
Sprintf
(
"Connect asset %s error: %s
\r\n
"
,
p
.
Asset
.
Hostname
,
err
)
...
@@ -215,7 +224,7 @@ func (p *ProxyServer) Proxy() {
...
@@ -215,7 +224,7 @@ func (p *ProxyServer) Proxy() {
// 创建Session
// 创建Session
sw
,
err
:=
CreateSession
(
p
)
sw
,
err
:=
CreateSession
(
p
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Errorf
(
"Request %s: Create session failed: %s"
,
p
.
UserConn
.
ID
(),
err
.
Error
())
logger
.
Errorf
(
"Request %s: Create session failed: %s"
,
p
.
UserConn
.
ID
(),
err
.
Error
())
return
return
}
}
defer
RemoveSession
(
sw
)
defer
RemoveSession
(
sw
)
...
...
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