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
56ca009c
Commit
56ca009c
authored
Jul 18, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/koko into dev
parents
7ded0bae
378a14f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
6 deletions
+47
-6
sftpvolume.go
pkg/httpd/sftpvolume.go
+10
-1
websshws.go
pkg/httpd/websshws.go
+1
-2
sftpconn.go
pkg/srvconn/sftpconn.go
+36
-3
No files found.
pkg/httpd/sftpvolume.go
View file @
56ca009c
...
@@ -172,7 +172,7 @@ func (u *UserVolume) UploadChunk(cid int, dirPath, chunkName string, reader io.R
...
@@ -172,7 +172,7 @@ func (u *UserVolume) UploadChunk(cid int, dirPath, chunkName string, reader io.R
func
(
u
*
UserVolume
)
MergeChunk
(
cid
,
total
int
,
dirPath
,
filename
string
)
(
elfinder
.
FileDir
,
error
)
{
func
(
u
*
UserVolume
)
MergeChunk
(
cid
,
total
int
,
dirPath
,
filename
string
)
(
elfinder
.
FileDir
,
error
)
{
path
:=
filepath
.
Join
(
dirPath
,
filename
)
path
:=
filepath
.
Join
(
dirPath
,
filename
)
logger
.
Debug
(
"merge chunk path: "
,
path
)
logger
.
Debug
(
"merge chunk path: "
,
path
)
var
rest
elfinder
.
FileDir
var
rest
elfinder
.
FileDir
fd
,
err
:=
u
.
UserSftp
.
Create
(
path
)
fd
,
err
:=
u
.
UserSftp
.
Create
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -249,6 +249,15 @@ func (u *UserVolume) Rename(oldNamePath, newName string) (elfinder.FileDir, erro
...
@@ -249,6 +249,15 @@ func (u *UserVolume) Rename(oldNamePath, newName string) (elfinder.FileDir, erro
}
}
func
(
u
*
UserVolume
)
Remove
(
path
string
)
error
{
func
(
u
*
UserVolume
)
Remove
(
path
string
)
error
{
var
res
os
.
FileInfo
var
err
error
res
,
err
=
u
.
UserSftp
.
Stat
(
path
)
if
err
!=
nil
{
return
err
}
if
res
.
IsDir
()
{
return
u
.
UserSftp
.
RemoveDirectory
(
path
)
}
return
u
.
UserSftp
.
Remove
(
path
)
return
u
.
UserSftp
.
Remove
(
path
)
}
}
...
...
pkg/httpd/websshws.go
View file @
56ca009c
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
"fmt"
"github.com/jumpserver/koko/pkg/model"
"io"
"io"
"net"
"net"
"strings"
"strings"
...
@@ -13,10 +12,10 @@ import (
...
@@ -13,10 +12,10 @@ import (
"github.com/gliderlabs/ssh"
"github.com/gliderlabs/ssh"
"github.com/kataras/neffos"
"github.com/kataras/neffos"
"github.com/satori/go.uuid"
"github.com/satori/go.uuid"
"github.com/jumpserver/koko/pkg/logger"
"github.com/jumpserver/koko/pkg/logger"
"github.com/jumpserver/koko/pkg/model"
"github.com/jumpserver/koko/pkg/proxy"
"github.com/jumpserver/koko/pkg/proxy"
"github.com/jumpserver/koko/pkg/service"
"github.com/jumpserver/koko/pkg/service"
)
)
...
...
pkg/srvconn/sftpconn.go
View file @
56ca009c
...
@@ -172,7 +172,7 @@ func (u *UserSftp) RemoveDirectory(path string) error {
...
@@ -172,7 +172,7 @@ func (u *UserSftp) RemoveDirectory(path string) error {
if
conn
==
nil
{
if
conn
==
nil
{
return
sftp
.
ErrSshFxPermissionDenied
return
sftp
.
ErrSshFxPermissionDenied
}
}
err
:=
conn
.
client
.
RemoveDirectory
(
realPath
)
err
:=
u
.
removeDirectoryAll
(
conn
.
client
,
realPath
)
filename
:=
realPath
filename
:=
realPath
isSucess
:=
false
isSucess
:=
false
operate
:=
model
.
OperateRemoveDir
operate
:=
model
.
OperateRemoveDir
...
@@ -183,6 +183,31 @@ func (u *UserSftp) RemoveDirectory(path string) error {
...
@@ -183,6 +183,31 @@ func (u *UserSftp) RemoveDirectory(path string) error {
return
err
return
err
}
}
func
(
u
*
UserSftp
)
removeDirectoryAll
(
conn
*
sftp
.
Client
,
path
string
)
error
{
var
err
error
var
files
[]
os
.
FileInfo
files
,
err
=
conn
.
ReadDir
(
path
)
if
err
!=
nil
{
return
err
}
for
_
,
item
:=
range
files
{
realPath
:=
filepath
.
Join
(
path
,
item
.
Name
())
if
item
.
IsDir
()
{
err
=
u
.
removeDirectoryAll
(
conn
,
realPath
)
if
err
!=
nil
{
return
err
}
continue
}
err
=
conn
.
Remove
(
realPath
)
if
err
!=
nil
{
return
err
}
}
return
conn
.
RemoveDirectory
(
path
)
}
func
(
u
*
UserSftp
)
Remove
(
path
string
)
error
{
func
(
u
*
UserSftp
)
Remove
(
path
string
)
error
{
req
:=
u
.
ParsePath
(
path
)
req
:=
u
.
ParsePath
(
path
)
if
req
.
host
==
""
{
if
req
.
host
==
""
{
...
@@ -496,9 +521,17 @@ func (u *UserSftp) LoopPushFTPLog() {
...
@@ -496,9 +521,17 @@ func (u *UserSftp) LoopPushFTPLog() {
dataChan
:=
make
(
chan
*
model
.
FTPLog
)
dataChan
:=
make
(
chan
*
model
.
FTPLog
)
go
u
.
SendFTPLog
(
dataChan
)
go
u
.
SendFTPLog
(
dataChan
)
defer
close
(
dataChan
)
defer
close
(
dataChan
)
var
timeoutSecond
time
.
Duration
for
{
for
{
switch
len
(
ftpLogList
)
{
case
0
:
timeoutSecond
=
time
.
Second
*
60
default
:
timeoutSecond
=
time
.
Second
*
1
}
select
{
select
{
case
<-
time
.
After
(
time
.
Second
*
5
)
:
case
<-
time
.
After
(
time
outSecond
)
:
case
logData
,
ok
:=
<-
u
.
LogChan
:
case
logData
,
ok
:=
<-
u
.
LogChan
:
if
!
ok
{
if
!
ok
{
return
return
...
@@ -613,7 +646,7 @@ func NewFakeFile(name string, isDir bool) *FakeFileInfo {
...
@@ -613,7 +646,7 @@ func NewFakeFile(name string, isDir bool) *FakeFileInfo {
}
}
}
}
func
NewFakeSymFile
(
name
string
)
*
FakeFileInfo
{
func
NewFakeSymFile
(
name
string
)
*
FakeFileInfo
{
return
&
FakeFileInfo
{
return
&
FakeFileInfo
{
name
:
name
,
name
:
name
,
modtime
:
time
.
Now
()
.
UTC
(),
modtime
:
time
.
Now
()
.
UTC
(),
...
...
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