Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
barry cho
Jpom
Commits
68d71b1e
Commit
68d71b1e
authored
5 years ago
by
不忘初心
Committed by
Gitee
5 years ago
Browse files
Options
Download
Email Patches
Plain Diff
回退 'Pull Request !133 : 提交解压bug'
parent
2ca06f4a
master
2.6.x
backup-dev
backup-thymeleaf
change-tab
dev
revert-merge-133-master
rsync-dev
v2.8.16
v2.8.15
v2.8.14
v2.8.13
v2.8.12
v2.8.11
v2.8.10
v2.8.9
v2.8.8
v2.8.7
v2.8.6
v2.8.5
v2.8.4
v2.8.3
v2.8.2
v2.8.1
v2.8.0
v2.8.0-fix
v2.7.3
v2.7.2
v2.7.1
v2.7.0
v2.6.4
v2.6.3
v2.6.2
v2.6.1
v2.6.0
v2.5.2
v2.5.1
v2.5.0.1_fix_docs
v2.5.0
v2.4.9
v2.4.8
v2.4.7
fix-2.8.0
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
modules/common/src/main/java/io/jpom/util/CommandUtil.java
+2
-4
modules/common/src/main/java/io/jpom/util/CommandUtil.java
modules/server/src/main/java/io/jpom/controller/node/ssh/SshFileController.java
+0
-20
...n/java/io/jpom/controller/node/ssh/SshFileController.java
modules/server/src/main/java/io/jpom/socket/handler/SshHandler.java
+10
-33
...rver/src/main/java/io/jpom/socket/handler/SshHandler.java
modules/server/src/main/resources/templates/node/ssh/file.html
+6
-37
...es/server/src/main/resources/templates/node/ssh/file.html
modules/server/src/main/resources/templates/node/ssh/terminal.html
+5
-21
...erver/src/main/resources/templates/node/ssh/terminal.html
with
23 additions
and
115 deletions
+23
-115
modules/common/src/main/java/io/jpom/util/CommandUtil.java
+
2
-
4
View file @
68d71b1e
...
...
@@ -113,11 +113,9 @@ public class CommandUtil {
* @throws IOException 异常
*/
public
static
void
asyncExeLocalCommand
(
File
file
,
String
command
)
throws
Exception
{
String
newCommand
=
StrUtil
.
replace
(
command
,
StrUtil
.
CRLF
,
StrUtil
.
SPACE
);
newCommand
=
StrUtil
.
replace
(
newCommand
,
StrUtil
.
LF
,
StrUtil
.
SPACE
);
DefaultSystemLog
.
getLog
().
info
(
newCommand
);
DefaultSystemLog
.
getLog
().
info
(
command
);
List
<
String
>
commands
=
getCommand
();
commands
.
add
(
newC
ommand
);
commands
.
add
(
c
ommand
);
ProcessBuilder
pb
=
new
ProcessBuilder
(
commands
);
if
(
file
!=
null
)
{
pb
.
directory
(
file
);
...
...
This diff is collapsed.
Click to expand it.
modules/server/src/main/java/io/jpom/controller/node/ssh/SshFileController.java
+
0
-
20
View file @
68d71b1e
...
...
@@ -185,26 +185,6 @@ public class SshFileController extends BaseServerController {
if
(
lsEntry
.
getAttrs
().
isDir
())
{
jsonObject
.
put
(
"dir"
,
true
);
jsonObject
.
put
(
"title"
,
lsEntry
.
getFilename
()
+
"【文件夹】"
);
}
else
if
(
lsEntry
.
getFilename
().
endsWith
(
".gz"
))
{
jsonObject
.
put
(
"gz"
,
true
);
jsonObject
.
put
(
"title"
,
lsEntry
.
getFilename
()
+
"【压缩包】"
);
long
fileSize
=
lsEntry
.
getAttrs
().
getSize
();
jsonObject
.
put
(
"size"
,
FileUtil
.
readableFileSize
(
fileSize
));
}
else
if
(
lsEntry
.
getFilename
().
endsWith
(
".tar"
))
{
jsonObject
.
put
(
"gtar"
,
true
);
jsonObject
.
put
(
"title"
,
lsEntry
.
getFilename
()
+
"【压缩包】"
);
long
fileSize
=
lsEntry
.
getAttrs
().
getSize
();
jsonObject
.
put
(
"size"
,
FileUtil
.
readableFileSize
(
fileSize
));
}
else
if
(
lsEntry
.
getFilename
().
endsWith
(
".rar"
))
{
jsonObject
.
put
(
"rar"
,
true
);
jsonObject
.
put
(
"title"
,
lsEntry
.
getFilename
()
+
"【压缩包】"
);
long
fileSize
=
lsEntry
.
getAttrs
().
getSize
();
jsonObject
.
put
(
"size"
,
FileUtil
.
readableFileSize
(
fileSize
));
}
else
if
(
lsEntry
.
getFilename
().
endsWith
(
".zip"
))
{
jsonObject
.
put
(
"zip"
,
true
);
jsonObject
.
put
(
"title"
,
lsEntry
.
getFilename
()
+
"【压缩包】"
);
long
fileSize
=
lsEntry
.
getAttrs
().
getSize
();
jsonObject
.
put
(
"size"
,
FileUtil
.
readableFileSize
(
fileSize
));
}
else
{
jsonObject
.
put
(
"title"
,
lsEntry
.
getFilename
());
long
fileSize
=
lsEntry
.
getAttrs
().
getSize
();
...
...
This diff is collapsed.
Click to expand it.
modules/server/src/main/java/io/jpom/socket/handler/SshHandler.java
+
10
-
33
View file @
68d71b1e
...
...
@@ -42,25 +42,17 @@ public class SshHandler extends BaseHandler {
public
void
afterConnectionEstablished
(
WebSocketSession
session
)
throws
Exception
{
SshModel
sshItem
=
(
SshModel
)
session
.
getAttributes
().
get
(
"sshItem"
);
Map
<
String
,
String
[]>
parameterMap
=
(
Map
<
String
,
String
[]>)
session
.
getAttributes
().
get
(
"parameterMap"
);
String
[]
fileDirAlls
=
null
;
//判断url是何操作请求
if
(
parameterMap
.
containsKey
(
"tail"
)){
fileDirAlls
=
parameterMap
.
get
(
"tail"
);
}
else
if
(
parameterMap
.
containsKey
(
"gz"
)){
fileDirAlls
=
parameterMap
.
get
(
"gz"
);
}
else
{
fileDirAlls
=
parameterMap
.
get
(
"zip"
);
}
//检查文件路径
String
fileDirAll
=
null
;
if
(
fileDirAlls
!=
null
&&
fileDirAlls
.
length
>
0
&&
!
StrUtil
.
isEmptyOrUndefined
(
fileDirAlls
[
0
]))
{
fileDirAll
=
fileDirAlls
[
0
];
String
[]
tails
=
parameterMap
.
get
(
"tail"
);
//
String
tail
=
null
;
if
(
tails
!=
null
&&
tails
.
length
>
0
&&
!
StrUtil
.
isEmptyOrUndefined
(
tails
[
0
]))
{
tail
=
tails
[
0
];
List
<
String
>
fileDirs
=
sshItem
.
getFileDirs
();
if
(
fileDirs
==
null
)
{
sendBinary
(
session
,
"没有配置路径"
);
return
;
}
File
file
=
FileUtil
.
file
(
fileDirAl
l
);
File
file
=
FileUtil
.
file
(
tai
l
);
boolean
find
=
false
;
for
(
String
fileDir
:
fileDirs
)
{
if
(
FileUtil
.
isSub
(
FileUtil
.
file
(
fileDir
),
file
))
{
...
...
@@ -84,27 +76,12 @@ public class SshHandler extends BaseHandler {
HANDLER_ITEM_CONCURRENT_HASH_MAP
.
put
(
session
.
getId
(),
handlerItem
);
//
Thread
.
sleep
(
1000
);
//截取当前操作文件父路径
String
fileLocalPath
=
null
;
if
(
fileDirAll
.
lastIndexOf
(
"/"
)
>
-
1
){
fileLocalPath
=
fileDirAll
.
substring
(
0
,
fileDirAll
.
lastIndexOf
(
"/"
));
}
if
(
fileDirAll
==
null
)
{
if
(
tail
==
null
)
{
this
.
call
(
session
,
StrUtil
.
CR
);
}
else
if
(
parameterMap
.
containsKey
(
"tail"
))
{
}
else
{
// 查看文件
fileDirAll
=
FileUtil
.
normalize
(
fileDirAll
);
this
.
call
(
session
,
StrUtil
.
format
(
"tail -f {}"
,
fileDirAll
));
this
.
call
(
session
,
StrUtil
.
CR
);
}
else
if
(
parameterMap
.
containsKey
(
"zip"
)){
//解压zip
fileDirAll
=
FileUtil
.
normalize
(
fileDirAll
);
this
.
call
(
session
,
StrUtil
.
format
(
"unzip -o {} -d "
+
"{}"
,
fileDirAll
,
fileLocalPath
));
this
.
call
(
session
,
StrUtil
.
CR
);
}
else
{
//解压 tar和tar.gz
fileDirAll
=
FileUtil
.
normalize
(
fileDirAll
);
this
.
call
(
session
,
StrUtil
.
format
(
"tar -xzvf {} -C "
+
"{}"
,
fileDirAll
,
fileLocalPath
));
tail
=
FileUtil
.
normalize
(
tail
);
this
.
call
(
session
,
StrUtil
.
format
(
"tail -f {}"
,
tail
));
this
.
call
(
session
,
StrUtil
.
CR
);
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/server/src/main/resources/templates/node/ssh/file.html
+
6
-
37
View file @
68d71b1e
...
...
@@ -38,21 +38,13 @@
<table
class=
"layui-table"
id=
"table"
lay-filter=
"table"
style=
"margin: 0;"
></table>
</body>
<script
type=
"text/html"
id=
"bar_monitor"
>
<
a
href
=
"
javascript:;
"
class
=
"
layui-btn layui-btn-sm layui-btn-warm
"
lay
-
event
=
"
terminal
"
>
终端
<
/a
>
{{
#
if
(
!
d
.
path
){
}}
<
a
href
=
"
javascript:;
"
class
=
"
layui-btn layui-btn-sm layui-btn-danger
"
lay
-
event
=
"
delete
"
>
删除
<
/a
>
{{
#
}
}}
{{
#
if
(
!
d
.
dir
&&
!
d
.
gz
&&
!
d
.
tar
&&
!
d
.
zip
&&
!
d
.
rar
){
}}
<
a
href
=
"
javascript:;
"
class
=
"
layui-btn layui-btn-sm layui-btn-warm
"
lay
-
event
=
"
terminal
"
>
终端
<
/a
>
{{
#
}
}}
{{
#
if
(
!
d
.
dir
){
}}
<
a
href
=
"
javascript:;
"
class
=
"
layui-btn layui-btn-sm layui-btn-normal
"
lay
-
event
=
"
download
"
>
下载
<
/a
>
{{
#
}
}}
{{
#
if
(
d
.
zip
){
}}
<
a
href
=
"
javascript:;
"
class
=
"
layui-btn layui-btn-sm layui-btn-normal
"
lay
-
event
=
"
compresszip
"
>
解压
<
/a
>
{{
#
}
}}
{{
#
if
(
d
.
gz
||
d
.
tar
){
}}
<
a
href
=
"
javascript:;
"
class
=
"
layui-btn layui-btn-sm layui-btn-normal
"
lay
-
event
=
"
compressgz
"
>
解压
<
/a
>
{{
#
}
}}
</script>
<script
type=
"text/javascript"
>
var
id
=
getQueryString
(
"
id
"
);
...
...
@@ -60,7 +52,7 @@
var
nowPath
=
''
;
var
rootPath
;
var
col
=
[
{
field
:
'
title
'
,
title
:
'
文件名称
'
,
event
:
'
rowClick
'
,
width
:
"
25%
"
,
sort
:
true
},
{
field
:
'
title
'
,
title
:
'
文件名称
'
,
event
:
'
rowClick
'
},
{
field
:
'
dir
'
,
title
:
'
文件类型
'
,
event
:
'
rowClick
'
,
templet
:
function
(
d
)
{
if
(
d
.
dir
)
{
...
...
@@ -69,9 +61,9 @@
return
'
文件
'
;
}
},
{
field
:
'
size
'
,
title
:
'
文件大小
'
,
event
:
'
rowClick
'
,
sort
:
true
},
{
field
:
'
modifyTime
'
,
title
:
'
修改时间
'
,
event
:
'
rowClick
'
,
sort
:
true
},
{
field
:
'
op
'
,
title
:
'
操作
'
,
align
:
'
center
'
,
toolbar
:
'
#bar_monitor
'
,
fixed
:
'
right
'
,
width
:
"
30%
"
}
{
field
:
'
size
'
,
title
:
'
文件大小
'
,
event
:
'
rowClick
'
},
{
field
:
'
modifyTime
'
,
title
:
'
修改时间
'
,
event
:
'
rowClick
'
},
{
field
:
'
op
'
,
title
:
'
操作
'
,
align
:
'
center
'
,
toolbar
:
'
#bar_monitor
'
,
fixed
:
'
right
'
}
];
function
loadSuccess
()
{
...
...
@@ -102,7 +94,6 @@
if
(
'
download
'
===
event
)
{
// 下载
if
(
!
data
.
dir
)
{
//打开一个浏览器窗口
window
.
open
(
"
./download.html?id=
"
+
id
+
"
&path=
"
+
rootPath
+
"
&name=
"
+
data
.
parentDir
);
}
}
else
if
(
'
terminal
'
===
event
)
{
...
...
@@ -114,29 +105,7 @@
tabChange
({
id
:
id
+
tailPtah
,
url
:
'
./node/ssh/terminal.html?id=
'
+
id
+
"
&tail=
"
+
tailPtah
,
title
:
data
.
name
+
'
-查看终端
'
,
});
}
else
if
(
'
compresszip
'
===
event
){
let
parentDir
=
formatePath
(
data
.
parentDir
);
var
zipPtah
=
rootPath
+
parentDir
;
if
(
!
rootPath
)
{
tailPtah
=
data
.
path
;
}
tabChange
({
id
:
id
+
zipPtah
,
url
:
'
./node/ssh/terminal.html?id=
'
+
id
+
"
&zip=
"
+
zipPtah
,
title
:
data
.
name
+
'
- zip解压终端
'
,
});
}
else
if
(
'
compressgz
'
===
event
){
let
parentDir
=
formatePath
(
data
.
parentDir
);
var
gzPtah
=
rootPath
+
parentDir
;
if
(
!
rootPath
)
{
gzPtah
=
data
.
path
;
}
tabChange
({
id
:
id
+
gzPtah
,
url
:
'
./node/ssh/terminal.html?id=
'
+
id
+
"
&gz=
"
+
gzPtah
,
title
:
data
.
name
+
'
- gz解压终端
'
,
title
:
data
.
name
+
'
- 文件终端
'
,
});
}
else
if
(
'
delete
'
===
event
)
{
let
path
=
rootPath
;
...
...
This diff is collapsed.
Click to expand it.
modules/server/src/main/resources/templates/node/ssh/terminal.html
+
5
-
21
View file @
68d71b1e
...
...
@@ -19,11 +19,7 @@
var
sock
;
// tail 文件
var
tail
=
getQueryString
(
"
tail
"
);
var
zip
=
getQueryString
(
"
zip
"
);
var
gz
=
getQueryString
(
"
gz
"
);
var
cursorBlink
=
!
tail
;
var
cursorBlinkZip
=
!
zip
;
var
cursorBlinkGz
=
!
gz
;
function
loadSuccess
()
{
top
.
layer
.
load
({
...
...
@@ -34,28 +30,16 @@
top
.
location
.
reload
();
}
});
if
(
tail
!==
null
){
var
url
=
getSocketHost
()
+
"
/ssh?userId=[[${session.user.getUserMd5Key()}]]&
"
+
"
sshId=[[${item?.id}]]&nodeId=system&type=ssh&
"
+
"
tail=
"
+
tail
;
}
else
if
(
zip
!==
null
){
var
url
=
getSocketHost
()
+
"
/ssh?userId=[[${session.user.getUserMd5Key()}]]&
"
+
"
sshId=[[${item?.id}]]&nodeId=system&type=ssh&
"
+
"
zip=
"
+
zip
;
}
else
if
(
gz
!==
null
){
var
url
=
getSocketHost
()
+
"
/ssh?userId=[[${session.user.getUserMd5Key()}]]&
"
+
"
sshId=[[${item?.id}]]&nodeId=system&type=ssh&
"
+
"
gz=
"
+
gz
;
}
var
url
=
getSocketHost
()
+
"
/ssh?userId=[[${session.user.getUserMd5Key()}]]&
"
+
"
sshId=[[${item?.id}]]&nodeId=system&type=ssh&
"
+
"
tail=
"
+
tail
;
var
terminal
=
document
.
getElementById
(
"
#terminal
"
);
term
=
new
window
.
Terminal
({
cursorBlink
:
cursorBlink
,
cursorBlinkGz
:
cursorBlinkGz
,
cursorBlinkZip
:
cursorBlinkZip
,
});
//
term
.
onData
(
function
(
data
)
{
if
(
tail
||
zip
||
gz
)
{
if
(
tail
)
{
return
;
}
sock
.
send
(
JSON
.
stringify
({
'
data
'
:
data
}));
...
...
@@ -64,7 +48,7 @@
// 监听按键
var
startX
=
2
;
term
.
onKey
(
function
(
key
)
{
if
(
tail
||
zip
||
gz
)
{
if
(
tail
)
{
return
;
}
var
ev
=
key
.
domEvent
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help