Commit 657fbc18 authored by Eric_Lee's avatar Eric_Lee Committed by Eric

修复关闭seesion的bug和移除无效的配置 (#80)

parent b8654e70
...@@ -30,27 +30,15 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver> ...@@ -30,27 +30,15 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>
# 设置日志级别 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL] # 设置日志级别 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL]
# LOG_LEVEL: INFO # LOG_LEVEL: INFO
# 日志存放的目录
# LOG_DIR: logs
# SSH白名单 # 和Jumpserver 保持心跳时间间隔 (seconds)
# ALLOW_SSH_USER: all
# SSH黑名单, 如果用户同时在白名单和黑名单,黑名单优先生效
# BLOCK_SSH_USER:
# -
# 和Jumpserver 保持心跳时间间隔
# HEARTBEAT_INTERVAL: 5 # HEARTBEAT_INTERVAL: 5
# Admin的名字,出问题会提示给用户
# ADMINS: ''
# SSH连接超时时间 (default 15 seconds) # SSH连接超时时间 (default 15 seconds)
# SSH_TIMEOUT: 15 # SSH_TIMEOUT: 15
# 语言 [en,zh] # 语言 [en,zh]
# LANGUAGE_CODE: zh # LANG: zh
# SFTP的根目录, 可选 /tmp, Home其他自定义目录 # SFTP的根目录, 可选 /tmp, Home其他自定义目录
# SFTP_ROOT: /tmp # SFTP_ROOT: /tmp
......
...@@ -17,19 +17,22 @@ var lock = new(sync.RWMutex) ...@@ -17,19 +17,22 @@ var lock = new(sync.RWMutex)
func HandleSessionTask(task model.TerminalTask) { func HandleSessionTask(task model.TerminalTask) {
switch task.Name { switch task.Name {
case "kill_session": case "kill_session":
KillSession(task.Args) if ok := KillSession(task.Args); ok{
service.FinishTask(task.ID) service.FinishTask(task.ID)
}
default: default:
} }
} }
func KillSession(sessionID string) { func KillSession(sessionID string) bool {
lock.RLock() lock.RLock()
defer lock.RUnlock() defer lock.RUnlock()
if sw, ok := sessionMap[sessionID]; ok { if sw, ok := sessionMap[sessionID]; ok {
sw.Terminate() sw.Terminate()
return true
} }
return false
} }
func GetAliveSessions() []string { func GetAliveSessions() []string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment