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
967ca75a
Commit
967ca75a
authored
Jan 21, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] load config from server
parent
0e9aa67c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
app.py
coco/app.py
+10
-10
interface.py
coco/interface.py
+2
-2
recorder.py
coco/recorder.py
+6
-6
sshd.py
coco/sshd.py
+1
-1
conf_example.py
conf_example.py
+2
-2
No files found.
coco/app.py
View file @
967ca75a
...
@@ -42,13 +42,13 @@ class Coco:
...
@@ -42,13 +42,13 @@ class Coco:
'LOG_DIR'
:
os
.
path
.
join
(
BASE_DIR
,
'logs'
),
'LOG_DIR'
:
os
.
path
.
join
(
BASE_DIR
,
'logs'
),
'SESSION_DIR'
:
os
.
path
.
join
(
BASE_DIR
,
'sessions'
),
'SESSION_DIR'
:
os
.
path
.
join
(
BASE_DIR
,
'sessions'
),
'ASSET_LIST_SORT_BY'
:
'hostname'
,
# hostname, ip
'ASSET_LIST_SORT_BY'
:
'hostname'
,
# hostname, ip
'
SSH_
PASSWORD_AUTH'
:
True
,
'PASSWORD_AUTH'
:
True
,
'
SSH_
PUBLIC_KEY_AUTH'
:
True
,
'PUBLIC_KEY_AUTH'
:
True
,
'HEARTBEAT_INTERVAL'
:
5
,
'HEARTBEAT_INTERVAL'
:
5
,
'MAX_CONNECTIONS'
:
500
,
'MAX_CONNECTIONS'
:
500
,
'ADMINS'
:
''
,
'ADMINS'
:
''
,
'
REPLAY_RECORD_ENGINE'
:
'server'
,
# local,
server
'
COMMAND_STORAGE'
:
{
'TYPE'
:
'server'
},
#
server
'
COMMAND_RECORD_ENGINE'
:
'server'
,
# local, server, elasticsearch(not yet)
'
REPLAY_RECORD_ENGINE'
:
'server'
,
}
}
def
__init__
(
self
,
name
=
None
,
root_path
=
None
):
def
__init__
(
self
,
name
=
None
,
root_path
=
None
):
...
@@ -93,13 +93,13 @@ class Coco:
...
@@ -93,13 +93,13 @@ class Coco:
def
make_logger
(
self
):
def
make_logger
(
self
):
create_logger
(
self
)
create_logger
(
self
)
# Todo: load some config from server like replay and common upload
def
load_extra_conf_from_server
(
self
):
def
load_extra_conf_from_server
(
self
):
pass
configs
=
self
.
service
.
load_config_from_server
()
self
.
config
.
update
(
configs
)
def
initial_recorder
(
self
):
def
get_recorder_class
(
self
):
self
.
replay_recorder_class
=
get_replay_recorder_class
(
self
)
self
.
replay_recorder_class
=
get_replay_recorder_class
(
self
.
config
)
self
.
command_recorder_class
=
get_command_recorder_class
(
self
)
self
.
command_recorder_class
=
get_command_recorder_class
(
self
.
config
)
def
new_command_recorder
(
self
):
def
new_command_recorder
(
self
):
return
self
.
command_recorder_class
(
self
)
return
self
.
command_recorder_class
(
self
)
...
@@ -111,7 +111,7 @@ class Coco:
...
@@ -111,7 +111,7 @@ class Coco:
self
.
make_logger
()
self
.
make_logger
()
self
.
service
.
initial
()
self
.
service
.
initial
()
self
.
load_extra_conf_from_server
()
self
.
load_extra_conf_from_server
()
self
.
initial_recorder
()
self
.
get_recorder_class
()
self
.
keep_heartbeat
()
self
.
keep_heartbeat
()
self
.
monitor_sessions
()
self
.
monitor_sessions
()
...
...
coco/interface.py
View file @
967ca75a
...
@@ -43,9 +43,9 @@ class SSHInterface(paramiko.ServerInterface):
...
@@ -43,9 +43,9 @@ class SSHInterface(paramiko.ServerInterface):
def
get_allowed_auths
(
self
,
username
):
def
get_allowed_auths
(
self
,
username
):
supported
=
[]
supported
=
[]
if
self
.
app
.
config
[
"
SSH_
PASSWORD_AUTH"
]:
if
self
.
app
.
config
[
"PASSWORD_AUTH"
]:
supported
.
append
(
"password"
)
supported
.
append
(
"password"
)
if
self
.
app
.
config
[
"
SSH_
PUBLIC_KEY_AUTH"
]:
if
self
.
app
.
config
[
"PUBLIC_KEY_AUTH"
]:
supported
.
append
(
"publickey"
)
supported
.
append
(
"publickey"
)
return
","
.
join
(
supported
)
return
","
.
join
(
supported
)
...
...
coco/recorder.py
View file @
967ca75a
...
@@ -11,7 +11,7 @@ import gzip
...
@@ -11,7 +11,7 @@ import gzip
import
json
import
json
import
shutil
import
shutil
from
jms_es_s
torage
import
ESStore
from
jms_es_s
dk
import
ESStore
from
.alignment
import
MemoryQueue
from
.alignment
import
MemoryQueue
...
@@ -237,17 +237,17 @@ class ESCommandRecorder(CommandRecorder, metaclass=Singleton):
...
@@ -237,17 +237,17 @@ class ESCommandRecorder(CommandRecorder, metaclass=Singleton):
print
(
"{} has been gc"
.
format
(
self
))
print
(
"{} has been gc"
.
format
(
self
))
def
get_command_recorder_class
(
app
):
def
get_command_recorder_class
(
config
):
command_
engine
=
app
.
config
[
"COMMAND_RECORD_ENGIN
E"
]
command_
storage
=
config
[
"COMMAND_STORAG
E"
]
if
command_
engine
==
"elasticsearch"
:
if
command_
storage
[
'TYPE'
]
==
"elasticsearch"
:
return
ESCommandRecorder
return
ESCommandRecorder
else
:
else
:
return
ServerCommandRecorder
return
ServerCommandRecorder
def
get_replay_recorder_class
(
app
):
def
get_replay_recorder_class
(
config
):
replay_engine
=
app
.
config
[
"REPLAY_RECORD_ENGINE"
]
replay_engine
=
config
[
"REPLAY_RECORD_ENGINE"
]
if
replay_engine
==
"server"
:
if
replay_engine
==
"server"
:
return
ServerReplayRecorder
return
ServerReplayRecorder
else
:
else
:
...
...
coco/sshd.py
View file @
967ca75a
...
@@ -89,7 +89,7 @@ class SSHServer:
...
@@ -89,7 +89,7 @@ class SSHServer:
def
dispatch
(
self
,
client
):
def
dispatch
(
self
,
client
):
request_type
=
client
.
request
.
type
request_type
=
client
.
request
.
type
if
request_type
==
'pty'
:
if
request_type
==
'pty'
or
request_type
==
'x11'
:
logger
.
info
(
"Request type `pty`, dispatch to interactive mode"
)
logger
.
info
(
"Request type `pty`, dispatch to interactive mode"
)
InteractiveServer
(
self
.
app
,
client
)
.
interact
()
InteractiveServer
(
self
.
app
,
client
)
.
interact
()
elif
request_type
==
'exec'
:
elif
request_type
==
'exec'
:
...
...
conf_example.py
View file @
967ca75a
...
@@ -49,10 +49,10 @@ class Config:
...
@@ -49,10 +49,10 @@ class Config:
# ASSET_LIST_SORT_BY = 'ip'
# ASSET_LIST_SORT_BY = 'ip'
# 登录是否支持密码认证
# 登录是否支持密码认证
#
SSH_
PASSWORD_AUTH = True
# PASSWORD_AUTH = True
# 登录是否支持秘钥认证
# 登录是否支持秘钥认证
#
SSH_
PUBLIC_KEY_AUTH = True
# PUBLIC_KEY_AUTH = True
# 和Jumpserver 保持心跳时间间隔
# 和Jumpserver 保持心跳时间间隔
# HEARTBEAT_INTERVAL = 5
# HEARTBEAT_INTERVAL = 5
...
...
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