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
40508030
Unverified
Commit
40508030
authored
Oct 28, 2019
by
Eric_Lee
Committed by
GitHub
Oct 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #124 from jumpserver/v52_bugfix
V52 bugfix
parents
623ab75f
4e6fe7c2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
29 deletions
+59
-29
go.mod
go.mod
+3
-4
go.sum
go.sum
+4
-4
sftp.go
pkg/handler/sftp.go
+2
-2
websshws.go
pkg/httpd/websshws.go
+14
-1
parsercmd.go
pkg/proxy/parsercmd.go
+32
-18
proxy.go
pkg/proxy/proxy.go
+2
-0
terminal.go
pkg/utils/terminal.go
+2
-0
No files found.
go.mod
View file @
40508030
...
...
@@ -20,7 +20,6 @@ require (
github.com/jarcoal/httpmock v1.0.4
github.com/kataras/neffos v0.0.7
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/leonelquinteros/gotext v1.4.0
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/olekukonko/tablewriter v0.0.1
...
...
@@ -29,9 +28,8 @@ require (
github.com/pkg/sftp v1.10.0
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.3.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca
golang.org/x/crypto v0.0.0-20190
701094942-4def268fd1a4
golang.org/x/crypto v0.0.0-20190
820162420-60c769a6c586
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
...
...
@@ -41,5 +39,6 @@ require (
replace (
github.com/gliderlabs/ssh v0.2.3-0.20190711180243-866d0ddf7991 => github.com/ibuler/ssh v0.1.6-0.20191022095544-d805cc9f27a8
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 => github.com/ibuler/crypto v0.0.0-20190715092645-911d13b3bf6e
github.com/pkg/sftp v1.10.0 => github.com/LeeEirc/sftp v1.10.2
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 => github.com/ibuler/crypto v0.0.0-20190715092645-911d13b3bf6e
)
go.sum
View file @
40508030
...
...
@@ -7,6 +7,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/LeeEirc/elfinder v0.0.2 h1:OnsOkZ3FVVKk91JxQQGwAULo78BSwPRN0yXaYcUK6Yk=
github.com/LeeEirc/elfinder v0.0.2/go.mod h1:VSfmUhE4Fvv+4Dfyo7Wmi44bdyDuIQgJtyi5EDcDSxE=
github.com/LeeEirc/sftp v1.10.2 h1:SGpj84RbStlwH+ThXYUsxtxtbzAzpUY8z5gQN4p12OI=
github.com/LeeEirc/sftp v1.10.2/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/aliyun/aliyun-oss-go-sdk v1.9.8 h1:BOflvK0Zs/zGmoabyFIzTg5c3kguktWTXEwewwbuba0=
github.com/aliyun/aliyun-oss-go-sdk v1.9.8/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
...
...
@@ -66,8 +68,6 @@ github.com/pires/go-proxyproto v0.0.0-20190615163442-2c19fd512994 h1:3ssKn22MN6o
github.com/pires/go-proxyproto v0.0.0-20190615163442-2c19fd512994/go.mod h1:6/gX3+E/IYGa0wMORlSMla999awQFdbaeQCHjSMKIzY=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.0 h1:DGA1KlA9esU6WcicH+P8PxFZOl15O6GYtab1cIJdOlE=
github.com/pkg/sftp v1.10.0/go.mod h1:NxmoDg/QLVWluQDUYG7XBZTLUpKeFa8e3aMf1BfjyHk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
...
...
@@ -77,8 +77,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.
3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q
=
github.com/stretchr/testify v1.
3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI
=
github.com/stretchr/testify v1.
4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk
=
github.com/stretchr/testify v1.
4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4
=
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
...
...
pkg/handler/sftp.go
View file @
40508030
...
...
@@ -32,12 +32,12 @@ func SftpHandler(sess ssh.Session) {
req
:=
sftp
.
NewRequestServer
(
sess
,
handlers
)
if
err
:=
req
.
Serve
();
err
==
io
.
EOF
{
_
=
req
.
Close
()
userSftp
.
Close
()
logger
.
Info
(
"sftp client exited session."
)
}
else
if
err
!=
nil
{
logger
.
Error
(
"sftp server completed with error:"
,
err
)
}
_
=
req
.
Close
()
userSftp
.
Close
()
}
func
NewSFTPHandler
(
user
*
model
.
User
,
addr
string
)
*
sftpHandler
{
...
...
pkg/httpd/websshws.go
View file @
40508030
...
...
@@ -121,7 +121,20 @@ func OnHostHandler(c *neffos.NSConn, msg neffos.Message) (err error) {
}
userR
,
userW
:=
io
.
Pipe
()
addr
,
_
,
_
:=
net
.
SplitHostPort
(
cc
.
Socket
()
.
Request
()
.
RemoteAddr
)
var
addr
string
request
:=
cc
.
Socket
()
.
Request
()
header
:=
request
.
Header
remoteAddr
:=
header
.
Get
(
"X-Forwarded-For"
)
if
remoteAddr
==
""
{
if
host
,
_
,
err
:=
net
.
SplitHostPort
(
request
.
RemoteAddr
);
err
==
nil
{
addr
=
host
}
else
{
addr
=
request
.
RemoteAddr
}
}
else
{
addr
=
strings
.
Split
(
remoteAddr
,
","
)[
0
]
}
client
:=
&
Client
{
Uuid
:
roomID
,
addr
:
addr
,
WinChan
:
make
(
chan
ssh
.
Window
,
100
),
Conn
:
c
,
...
...
pkg/proxy/parsercmd.go
View file @
40508030
...
...
@@ -19,56 +19,70 @@ func NewCmdParser() *CmdParser {
}
type
CmdParser
struct
{
term
*
utils
.
Terminal
reader
io
.
ReadCloser
writer
io
.
WriteCloser
currentLines
[]
string
lock
*
sync
.
Mutex
maxLength
int
term
*
utils
.
Terminal
reader
io
.
ReadCloser
writer
io
.
WriteCloser
currentLines
[]
string
lock
*
sync
.
Mutex
maxLength
int
currentLength
int
closed
chan
struct
{}
}
func
(
cp
*
CmdParser
)
WriteData
(
p
[]
byte
)
(
int
,
error
)
{
func
(
cp
*
CmdParser
)
WriteData
(
p
[]
byte
)
(
int
,
error
)
{
return
cp
.
writer
.
Write
(
p
)
}
func
(
cp
*
CmdParser
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
return
len
(
p
),
nil
func
(
cp
*
CmdParser
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
return
len
(
p
),
nil
}
func
(
cp
*
CmdParser
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
func
(
cp
*
CmdParser
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
return
cp
.
reader
.
Read
(
p
)
}
func
(
cp
*
CmdParser
)
Close
()
error
{
func
(
cp
*
CmdParser
)
Close
()
error
{
select
{
case
<-
cp
.
closed
:
return
nil
default
:
close
(
cp
.
closed
)
}
return
cp
.
writer
.
Close
()
}
func
(
cp
*
CmdParser
)
initial
()
{
cp
.
reader
,
cp
.
writer
=
io
.
Pipe
()
cp
.
currentLines
=
make
([]
string
,
0
)
cp
.
reader
,
cp
.
writer
=
io
.
Pipe
()
cp
.
currentLines
=
make
([]
string
,
0
)
cp
.
lock
=
new
(
sync
.
Mutex
)
cp
.
maxLength
=
1024
cp
.
currentLength
=
0
cp
.
closed
=
make
(
chan
struct
{})
cp
.
term
=
utils
.
NewTerminal
(
cp
,
""
)
cp
.
term
.
SetEcho
(
false
)
go
func
()
{
logger
.
Debug
(
"command Parser start"
)
defer
logger
.
Debug
(
"command Parser close"
)
inloop
:
for
{
line
,
err
:=
cp
.
term
.
ReadLine
()
if
err
!=
nil
{
break
if
err
!=
nil
{
select
{
case
<-
cp
.
closed
:
goto
outloop
default
:
}
goto
inloop
}
cp
.
lock
.
Lock
()
cp
.
currentLength
+=
len
(
line
)
if
cp
.
currentLength
<
cp
.
maxLength
{
cp
.
currentLines
=
append
(
cp
.
currentLines
,
line
)
cp
.
currentLines
=
append
(
cp
.
currentLines
,
line
)
}
cp
.
lock
.
Unlock
()
}
outloop
:
}()
}
...
...
@@ -83,7 +97,7 @@ func (cp *CmdParser) Parse() string {
defer
cp
.
lock
.
Unlock
()
output
:=
strings
.
TrimSpace
(
strings
.
Join
(
cp
.
currentLines
,
"
\r\n
"
))
output
=
cp
.
parsePS1
(
output
)
cp
.
currentLines
=
make
([]
string
,
0
)
cp
.
currentLines
=
make
([]
string
,
0
)
cp
.
currentLength
=
0
return
output
}
pkg/proxy/proxy.go
View file @
40508030
...
...
@@ -221,6 +221,8 @@ func (p *ProxyServer) Proxy() {
// 创建Session
sw
,
err
:=
CreateSession
(
p
)
if
err
!=
nil
{
// 创建srv成功,但session创建失败,关闭srvConn
_
=
srvConn
.
Close
()
return
}
defer
RemoveSession
(
sw
)
...
...
pkg/utils/terminal.go
View file @
40508030
...
...
@@ -801,6 +801,8 @@ func (t *Terminal) readLine() (line string, err error) {
if
!
t
.
pasteActive
{
if
key
==
keyCtrlD
{
if
len
(
t
.
line
)
==
0
{
// as key has already handled, we need update remainder data,
t
.
remainder
=
rest
return
""
,
io
.
EOF
}
}
...
...
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