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
fdc95a90
Unverified
Commit
fdc95a90
authored
Nov 07, 2019
by
老广
Committed by
GitHub
Nov 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #278 from jumpserver/dev
Dev
parents
cbc752df
b72ba6b6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
3 deletions
+35
-3
.dockerignore
.dockerignore
+1
-0
app.py
coco/httpd/app.py
+4
-0
elfinder.full.js
coco/httpd/static/plugins/elfinder/elfinder.full.js
+2
-0
interactive.py
coco/interactive.py
+3
-0
logger.py
coco/logger.py
+23
-2
proxy.py
coco/proxy.py
+2
-1
No files found.
.dockerignore
View file @
fdc95a90
.git
.git
logs/*
logs/*
keys/*
keys/*
data
coco/httpd/app.py
View file @
fdc95a90
...
@@ -29,10 +29,14 @@ socket_io.on_error_default(lambda x: logger.exception(x))
...
@@ -29,10 +29,14 @@ socket_io.on_error_default(lambda x: logger.exception(x))
class
HttpServer
:
class
HttpServer
:
@staticmethod
@staticmethod
def
run
():
def
run
():
import
time
host
=
config
[
"BIND_HOST"
]
host
=
config
[
"BIND_HOST"
]
port
=
config
[
"HTTPD_PORT"
]
port
=
config
[
"HTTPD_PORT"
]
print
(
'Starting websocket server at {}:{}'
.
format
(
host
,
port
))
print
(
'Starting websocket server at {}:{}'
.
format
(
host
,
port
))
while
True
:
socket_io
.
run
(
app
,
port
=
port
,
host
=
host
,
debug
=
False
)
socket_io
.
run
(
app
,
port
=
port
,
host
=
host
,
debug
=
False
)
time
.
sleep
(
60
)
print
(
"Error occur, rerun websocket server"
)
@staticmethod
@staticmethod
def
shutdown
():
def
shutdown
():
...
...
coco/httpd/static/plugins/elfinder/elfinder.full.js
View file @
fdc95a90
...
@@ -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
;
});
...
...
coco/interactive.py
View file @
fdc95a90
...
@@ -142,6 +142,9 @@ class InteractiveServer:
...
@@ -142,6 +142,9 @@ class InteractiveServer:
self
.
refresh_assets_nodes
()
self
.
refresh_assets_nodes
()
elif
opt
in
[
'h'
,
'H'
]:
elif
opt
in
[
'h'
,
'H'
]:
self
.
display_banner
()
self
.
display_banner
()
elif
opt
==
'#*32789'
:
from
.logger
import
append_engineio_logger
append_engineio_logger
()
else
:
else
:
self
.
search_and_proxy_assets
(
opt
)
self
.
search_and_proxy_assets
(
opt
)
...
...
coco/logger.py
View file @
fdc95a90
...
@@ -9,7 +9,7 @@ from logging.config import dictConfig
...
@@ -9,7 +9,7 @@ from logging.config import dictConfig
from
.conf
import
config
as
app_config
from
.conf
import
config
as
app_config
def
create_logger
():
def
get_logger_config
():
level
=
app_config
[
'LOG_LEVEL'
]
level
=
app_config
[
'LOG_LEVEL'
]
log_dir
=
app_config
[
'LOG_DIR'
]
log_dir
=
app_config
[
'LOG_DIR'
]
filename
=
'coco-{}.log'
.
format
(
socket
.
gethostname
())
filename
=
'coco-{}.log'
.
format
(
socket
.
gethostname
())
...
@@ -21,6 +21,7 @@ def create_logger():
...
@@ -21,6 +21,7 @@ def create_logger():
'level'
:
level
,
'level'
:
level
,
'propagate'
:
False
,
'propagate'
:
False
,
}
}
config
=
dict
(
config
=
dict
(
version
=
1
,
version
=
1
,
formatters
=
{
formatters
=
{
...
@@ -48,7 +49,7 @@ def create_logger():
...
@@ -48,7 +49,7 @@ def create_logger():
'class'
:
'logging.handlers.RotatingFileHandler'
,
'class'
:
'logging.handlers.RotatingFileHandler'
,
'formatter'
:
'main'
,
'formatter'
:
'main'
,
'filename'
:
log_path
,
'filename'
:
log_path
,
'maxBytes'
:
1024
*
1024
*
100
,
'maxBytes'
:
1024
*
1024
*
100
,
'backupCount'
:
7
,
'backupCount'
:
7
,
},
},
},
},
...
@@ -61,6 +62,26 @@ def create_logger():
...
@@ -61,6 +62,26 @@ def create_logger():
)
)
if
level
.
lower
()
==
'debug'
:
if
level
.
lower
()
==
'debug'
:
config
[
'loggers'
][
'paramiko'
]
=
main_setting
config
[
'loggers'
][
'paramiko'
]
=
main_setting
# config['loggers']['socket.io'] = main_setting
# config['loggers']['engineio'] = main_setting
return
config
def
create_logger
():
config
=
get_logger_config
()
dictConfig
(
config
)
logger
=
logging
.
getLogger
()
return
logger
def
append_engineio_logger
():
main_setting
=
{
'handlers'
:
[
'console'
,
'file'
],
'level'
:
'DEBUG'
,
'propagate'
:
False
,
}
config
=
get_logger_config
()
config
[
'loggers'
][
'engineio'
]
=
main_setting
dictConfig
(
config
)
dictConfig
(
config
)
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
return
logger
return
logger
...
...
coco/proxy.py
View file @
fdc95a90
...
@@ -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