Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
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
coco
Commits
b72ba6b6
Commit
b72ba6b6
authored
Nov 07, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/coco into dev
parents
42038786
afe57038
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
12 deletions
+29
-12
connector.py
coco/httpd/elfinder/connector.py
+1
-1
base.py
coco/httpd/elfinder/volumes/base.py
+2
-1
sftp.py
coco/httpd/elfinder/volumes/sftp.py
+21
-7
elfinder.full.js
coco/httpd/static/plugins/elfinder/elfinder.full.js
+3
-2
proxy.py
coco/proxy.py
+2
-1
No files found.
coco/httpd/elfinder/connector.py
View file @
b72ba6b6
...
@@ -273,7 +273,7 @@ class ElFinderConnector:
...
@@ -273,7 +273,7 @@ class ElFinderConnector:
upload_paths
=
self
.
data
.
get
(
'upload_path[]'
)
upload_paths
=
self
.
data
.
get
(
'upload_path[]'
)
if
self
.
data
.
get
(
'chunk'
)
and
self
.
data
.
get
(
'cid'
):
if
self
.
data
.
get
(
'chunk'
)
and
self
.
data
.
get
(
'cid'
):
self
.
response
.
update
(
self
.
response
.
update
(
volume
.
upload_as_chunk
(
volume
.
upload_as_chunk
(
self
.
data
.
get
(
'cid'
),
self
.
request
.
files
,
self
.
data
.
get
(
'chunk'
),
parent
,
upload_paths
self
.
request
.
files
,
self
.
data
.
get
(
'chunk'
),
parent
,
upload_paths
)
)
)
)
...
...
coco/httpd/elfinder/volumes/base.py
View file @
b72ba6b6
...
@@ -14,6 +14,7 @@ class BaseVolume:
...
@@ -14,6 +14,7 @@ class BaseVolume:
self
.
path_sep
=
'/'
self
.
path_sep
=
'/'
self
.
dir_mode
=
'0o755'
self
.
dir_mode
=
'0o755'
self
.
file_mode
=
'0o644'
self
.
file_mode
=
'0o644'
#
#
# @classmethod
# @classmethod
# def get_volume(cls, request):
# def get_volume(cls, request):
...
@@ -226,7 +227,7 @@ class BaseVolume:
...
@@ -226,7 +227,7 @@ class BaseVolume:
"""
"""
raise
NotImplementedError
raise
NotImplementedError
def
upload_as_chunk
(
self
,
files
,
chunk_name
,
parent
,
upload_path
):
def
upload_as_chunk
(
self
,
cid
,
files
,
chunk_name
,
parent
,
upload_path
):
"""
"""
Upload a large file as chunk
Upload a large file as chunk
:param files:
:param files:
...
...
coco/httpd/elfinder/volumes/sftp.py
View file @
b72ba6b6
...
@@ -17,10 +17,13 @@ class SFTPVolume(BaseVolume):
...
@@ -17,10 +17,13 @@ class SFTPVolume(BaseVolume):
self
.
sftp
=
sftp
self
.
sftp
=
sftp
self
.
root_name
=
'Home'
self
.
root_name
=
'Home'
self
.
_stat_cache
=
{}
self
.
_stat_cache
=
{}
self
.
_fd_cache
=
dict
()
self
.
lock
=
threading
.
Lock
()
self
.
lock
=
threading
.
Lock
()
super
(
SFTPVolume
,
self
)
.
__init__
()
super
(
SFTPVolume
,
self
)
.
__init__
()
def
close
(
self
):
def
close
(
self
):
for
fd
in
self
.
_fd_cache
.
values
():
fd
.
close
()
self
.
sftp
.
close
()
self
.
sftp
.
close
()
def
get_volume_id
(
self
):
def
get_volume_id
(
self
):
...
@@ -250,7 +253,7 @@ class SFTPVolume(BaseVolume):
...
@@ -250,7 +253,7 @@ class SFTPVolume(BaseVolume):
added
.
append
(
self
.
_info
(
path
))
added
.
append
(
self
.
_info
(
path
))
return
{
'added'
:
added
}
return
{
'added'
:
added
}
def
upload_as_chunk
(
self
,
files
,
chunk_name
,
parent
,
upload_path
):
def
upload_as_chunk
(
self
,
cid
,
files
,
chunk_name
,
parent
,
upload_path
):
added
=
[]
added
=
[]
parent_path
=
self
.
_path
(
parent
)
parent_path
=
self
.
_path
(
parent
)
item
=
files
.
get
(
'upload[]'
)
item
=
files
.
get
(
'upload[]'
)
...
@@ -258,28 +261,39 @@ class SFTPVolume(BaseVolume):
...
@@ -258,28 +261,39 @@ class SFTPVolume(BaseVolume):
filename
=
'.'
.
join
(
__tmp
[:
-
2
])
filename
=
'.'
.
join
(
__tmp
[:
-
2
])
num
,
total
=
__tmp
[
-
2
]
.
split
(
'_'
)
num
,
total
=
__tmp
[
-
2
]
.
split
(
'_'
)
num
,
total
=
int
(
num
),
int
(
total
)
num
,
total
=
int
(
num
),
int
(
total
)
if
len
(
upload_path
)
==
1
and
(
parent
!=
upload_path
[
0
])
and
(
filename
in
upload_path
[
0
]):
if
upload_path
and
len
(
upload_path
)
==
1
and
(
filename
in
upload_path
[
0
]):
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
))
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
))
el
se
:
el
if
upload_path
and
parent
!=
upload_path
[
0
]
:
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
),
filename
)
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
),
filename
)
else
:
path
=
self
.
_join
(
parent_path
,
filename
)
remote_path
=
self
.
_remote_path
(
path
)
remote_path
=
self
.
_remote_path
(
path
)
if
num
==
0
:
if
num
==
0
:
infos
=
self
.
_list
(
os
.
path
.
dirname
(
path
))
infos
=
self
.
_list
(
os
.
path
.
dirname
(
path
))
files_exist
=
[
d
[
'name'
]
for
d
in
infos
]
files_exist
=
[
d
[
'name'
]
for
d
in
infos
]
if
item
.
filename
in
files_exist
:
if
item
.
filename
in
files_exist
:
raise
OSError
(
"File {} exits"
.
format
(
remote_path
))
raise
OSError
(
"File {} exits"
.
format
(
remote_path
))
with
self
.
sftp
.
open
(
remote_path
,
'a'
)
as
rf
:
if
cid
not
in
self
.
_fd_cache
:
for
data
in
item
:
rf
=
self
.
sftp
.
open
(
remote_path
,
"a"
)
rf
.
write
(
data
)
self
.
_fd_cache
[
cid
]
=
rf
else
:
rf
=
self
.
_fd_cache
.
get
(
cid
)
for
data
in
item
:
rf
.
write
(
data
)
if
num
!=
total
:
if
num
!=
total
:
return
{
'added'
:
added
}
return
{
'added'
:
added
}
else
:
else
:
rf
.
close
()
self
.
_fd_cache
.
pop
(
cid
)
return
{
'added'
:
added
,
'_chunkmerged'
:
filename
,
'_name'
:
filename
}
return
{
'added'
:
added
,
'_chunkmerged'
:
filename
,
'_name'
:
filename
}
def
upload_chunk_merge
(
self
,
parent
,
chunk
,
upload_path
):
def
upload_chunk_merge
(
self
,
parent
,
chunk
,
upload_path
):
parent_path
=
self
.
_path
(
parent
)
parent_path
=
self
.
_path
(
parent
)
if
len
(
upload_path
)
==
1
and
(
parent
!=
upload_path
[
0
]):
if
upload_path
and
len
(
upload_path
)
==
1
and
(
chunk
in
upload_path
[
0
]):
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
))
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
))
elif
upload_path
and
(
parent
!=
upload_path
[
0
]):
path
=
self
.
_join
(
parent_path
,
upload_path
[
0
]
.
lstrip
(
self
.
path_sep
),
chunk
)
else
:
else
:
path
=
self
.
_join
(
parent_path
,
chunk
)
path
=
self
.
_join
(
parent_path
,
chunk
)
return
{
"added"
:
[
self
.
_info
(
path
)]}
return
{
"added"
:
[
self
.
_info
(
path
)]}
...
...
coco/httpd/static/plugins/elfinder/elfinder.full.js
View file @
b72ba6b6
...
@@ -14230,6 +14230,8 @@ $.fn.elfindercwd = function(fm, options) {
...
@@ -14230,6 +14230,8 @@ $.fn.elfindercwd = function(fm, options) {
selectCheckbox
&&
selectAllCheckbox
.
find
(
'input'
).
prop
(
'checked'
,
true
);
selectCheckbox
&&
selectAllCheckbox
.
find
(
'input'
).
prop
(
'checked'
,
true
);
fm
.
lazy
(
function
()
{
fm
.
lazy
(
function
()
{
var
files
;
var
files
;
// fix select all display; remove cwd disable status
cwd
.
find
(
'[id]:not(.'
+
clSelected
+
'):not(.elfinder-cwd-parent)'
).
removeClass
(
clDisabled
);
cwd
.
find
(
'[id]:not(.'
+
clSelected
+
'):not(.elfinder-cwd-parent)'
).
trigger
(
evtSelect
);
cwd
.
find
(
'[id]:not(.'
+
clSelected
+
'):not(.elfinder-cwd-parent)'
).
trigger
(
evtSelect
);
if
(
fm
.
maxTargets
&&
(
incHashes
||
cwdHashes
).
length
>
fm
.
maxTargets
)
{
if
(
fm
.
maxTargets
&&
(
incHashes
||
cwdHashes
).
length
>
fm
.
maxTargets
)
{
files
=
$
.
map
(
incHashes
||
cwdHashes
,
function
(
hash
)
{
return
fm
.
file
(
hash
)
||
null
;
});
files
=
$
.
map
(
incHashes
||
cwdHashes
,
function
(
hash
)
{
return
fm
.
file
(
hash
)
||
null
;
});
...
@@ -33643,4 +33645,4 @@ elFinder.prototype.commands.view = function() {
...
@@ -33643,4 +33645,4 @@ elFinder.prototype.commands.view = function() {
};
};
return
elFinder
;
return
elFinder
;
}));
}));
\ No newline at end of file
coco/proxy.py
View file @
b72ba6b6
...
@@ -118,14 +118,15 @@ class ProxyServer:
...
@@ -118,14 +118,15 @@ class ProxyServer:
self
.
get_system_user_username_if_need
()
self
.
get_system_user_username_if_need
()
self
.
get_system_user_auth_or_manual_set
()
self
.
get_system_user_auth_or_manual_set
()
self
.
send_connecting_message
()
self
.
send_connecting_message
()
logger
.
info
(
"Connect to {}:{} ..."
.
format
(
self
.
asset
.
hostname
,
self
.
asset
.
ssh_port
))
if
not
self
.
validate_permission
():
if
not
self
.
validate_permission
():
msg
=
_
(
'No permission'
)
msg
=
_
(
'No permission'
)
self
.
client
.
send_unicode
(
warning
(
wr
(
msg
,
before
=
2
,
after
=
0
)))
self
.
client
.
send_unicode
(
warning
(
wr
(
msg
,
before
=
2
,
after
=
0
)))
server
=
None
server
=
None
elif
self
.
system_user
.
protocol
==
'telnet'
:
elif
self
.
system_user
.
protocol
==
'telnet'
:
logger
.
info
(
"Connect to {}:{} ..."
.
format
(
self
.
asset
.
hostname
,
self
.
asset
.
telnet_port
))
server
=
self
.
get_telnet_server_conn
()
server
=
self
.
get_telnet_server_conn
()
elif
self
.
system_user
.
protocol
==
'ssh'
:
elif
self
.
system_user
.
protocol
==
'ssh'
:
logger
.
info
(
"Connect to {}:{} ..."
.
format
(
self
.
asset
.
hostname
,
self
.
asset
.
ssh_port
))
server
=
self
.
get_ssh_server_conn
()
server
=
self
.
get_ssh_server_conn
()
else
:
else
:
server
=
None
server
=
None
...
...
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