@pyrokine/mcp-ssh 1.3.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,13 +13,22 @@ export interface ForwardDependencies {
13
13
  export declare class ForwardManager {
14
14
  private sessions;
15
15
  private dispatchers;
16
+ private dependencies;
16
17
  private idCounter;
17
- forwardLocal(deps: ForwardDependencies, alias: string, localPort: number, remoteHost: string, remotePort: number, localHost?: string): Promise<string>;
18
+ private readonly idleTimeoutMs;
19
+ private idleSweeper;
20
+ constructor();
21
+ forwardLocal(deps: ForwardDependencies, alias: string, localPort: number, remoteHost: string, remotePort: number, localHost?: string): Promise<{
22
+ forwardId: string;
23
+ localPort: number;
24
+ }>;
18
25
  forwardRemote(deps: ForwardDependencies, alias: string, remotePort: number, localHost: string, localPort: number, remoteHost?: string): Promise<string>;
19
26
  close(forwardId: string, deps?: ForwardDependencies): boolean;
20
27
  /** 关闭指定 alias 的所有转发(disconnect 时调用,不需要 unforwardIn) */
21
28
  closeByAlias(alias: string): void;
22
29
  list(): PortForwardInfo[];
30
+ private startIdleSweeper;
31
+ private sweepIdle;
23
32
  /**
24
33
  * 确保 SSH session 有共享的 tcp connection dispatcher
25
34
  * 所有 remote forward 共用一个 dispatcher,根据 destIP/destPort 路由
@@ -7,12 +7,33 @@ import * as net from 'net';
7
7
  export class ForwardManager {
8
8
  sessions = new Map();
9
9
  dispatchers = new Map(); // alias → dispatcher
10
+ dependencies = null;
10
11
  idCounter = 0;
12
+ // 默认 idle timeout 1 小时,长时间无连接活动的 forward 自动关闭
13
+ idleTimeoutMs = Number(process.env.SSH_MCP_FORWARD_IDLE_TIMEOUT_MS) || 3600_000;
14
+ idleSweeper = null;
15
+ constructor() {
16
+ this.startIdleSweeper();
17
+ }
11
18
  async forwardLocal(deps, alias, localPort, remoteHost, remotePort, localHost = '127.0.0.1') {
19
+ this.dependencies = deps;
12
20
  const client = deps.getClient(alias);
13
21
  const forwardId = this.generateId();
14
22
  return new Promise((resolve, reject) => {
23
+ const fwdState = { ref: null };
15
24
  const server = net.createServer((socket) => {
25
+ const fwd = fwdState.ref;
26
+ if (fwd) {
27
+ fwd.activeConnections += 1;
28
+ fwd.lastActivityAt = Date.now();
29
+ }
30
+ const onClose = () => {
31
+ if (fwd) {
32
+ fwd.activeConnections = Math.max(0, fwd.activeConnections - 1);
33
+ fwd.lastActivityAt = Date.now();
34
+ }
35
+ };
36
+ socket.once('close', onClose);
16
37
  client.forwardOut(socket.remoteAddress || '127.0.0.1', socket.remotePort || 0, remoteHost, remotePort, (err, stream) => {
17
38
  if (err) {
18
39
  socket.end();
@@ -25,23 +46,30 @@ export class ForwardManager {
25
46
  reject(new Error(`Local forward failed: ${err.message}`));
26
47
  });
27
48
  server.listen(localPort, localHost, () => {
28
- this.sessions.set(forwardId, {
49
+ const addr = server.address();
50
+ const actualPort = addr && typeof addr === 'object' && typeof addr.port === 'number' ? addr.port : localPort;
51
+ const session = {
29
52
  id: forwardId,
30
53
  alias,
31
54
  type: 'local',
32
55
  localHost,
33
- localPort,
56
+ localPort: actualPort,
34
57
  remoteHost,
35
58
  remotePort,
36
59
  server,
37
60
  createdAt: Date.now(),
38
61
  active: true,
39
- });
40
- resolve(forwardId);
62
+ activeConnections: 0,
63
+ lastActivityAt: Date.now(),
64
+ };
65
+ this.sessions.set(forwardId, session);
66
+ fwdState.ref = session;
67
+ resolve({ forwardId, localPort: actualPort });
41
68
  });
42
69
  });
43
70
  }
44
71
  async forwardRemote(deps, alias, remotePort, localHost, localPort, remoteHost = '127.0.0.1') {
72
+ this.dependencies = deps;
45
73
  const client = deps.getClient(alias);
46
74
  const forwardId = this.generateId();
47
75
  return new Promise((resolve, reject) => {
@@ -60,6 +88,8 @@ export class ForwardManager {
60
88
  remotePort,
61
89
  createdAt: Date.now(),
62
90
  active: true,
91
+ activeConnections: 0,
92
+ lastActivityAt: Date.now(),
63
93
  });
64
94
  this.ensureTcpDispatcher(alias, client);
65
95
  resolve(forwardId);
@@ -85,7 +115,8 @@ export class ForwardManager {
85
115
  const client = deps.getClient(fwd.alias);
86
116
  client.unforwardIn(fwd.remoteHost, fwd.remotePort);
87
117
  }
88
- catch { /* session 可能已断开 */
118
+ catch {
119
+ /* session 可能已断开 */
89
120
  }
90
121
  this.removeTcpDispatcherIfEmpty(fwd.alias);
91
122
  }
@@ -114,7 +145,8 @@ export class ForwardManager {
114
145
  try {
115
146
  state.client.removeListener('tcp connection', state.handler);
116
147
  }
117
- catch { /* client 可能已关闭 */
148
+ catch {
149
+ /* client 可能已关闭 */
118
150
  }
119
151
  this.dispatchers.delete(alias);
120
152
  }
@@ -136,6 +168,27 @@ export class ForwardManager {
136
168
  }
137
169
  return result;
138
170
  }
171
+ startIdleSweeper() {
172
+ if (this.idleSweeper) {
173
+ return;
174
+ }
175
+ this.idleSweeper = setInterval(() => this.sweepIdle(), 5 * 60_000);
176
+ if (typeof this.idleSweeper.unref === 'function') {
177
+ this.idleSweeper.unref();
178
+ }
179
+ }
180
+ sweepIdle() {
181
+ const now = Date.now();
182
+ for (const [id, fwd] of this.sessions) {
183
+ if (!fwd.active) {
184
+ continue;
185
+ }
186
+ if (fwd.activeConnections === 0 && now - fwd.lastActivityAt > this.idleTimeoutMs) {
187
+ console.warn(`[mcp-ssh] Forward ${id} (${fwd.type}, alias=${fwd.alias}) idle ${Math.round((now - fwd.lastActivityAt) / 1000)}s with 0 connections > ${Math.round(this.idleTimeoutMs / 1000)}s, auto-closing`);
188
+ this.close(id, this.dependencies ?? undefined);
189
+ }
190
+ }
191
+ }
139
192
  /**
140
193
  * 确保 SSH session 有共享的 tcp connection dispatcher
141
194
  * 所有 remote forward 共用一个 dispatcher,根据 destIP/destPort 路由
@@ -153,9 +206,22 @@ export class ForwardManager {
153
206
  fwd.remotePort === info.destPort) {
154
207
  const stream = accept();
155
208
  const socket = net.createConnection(fwd.localPort, fwd.localHost);
209
+ fwd.activeConnections += 1;
210
+ fwd.lastActivityAt = Date.now();
211
+ let closed = false;
212
+ const onClose = () => {
213
+ if (closed) {
214
+ return;
215
+ }
216
+ closed = true;
217
+ fwd.activeConnections = Math.max(0, fwd.activeConnections - 1);
218
+ fwd.lastActivityAt = Date.now();
219
+ };
156
220
  socket.pipe(stream).pipe(socket);
157
221
  socket.on('error', () => stream.close());
222
+ socket.once('close', onClose);
158
223
  stream.on('error', () => socket.destroy());
224
+ stream.once('close', onClose);
159
225
  return;
160
226
  }
161
227
  }
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * A comprehensive SSH MCP Server for Claude Code
6
6
  *
7
7
  * Features:
8
- * - Multiple authentication methods (password, key, agent)
8
+ * - Multiple authentication methods (password, key)
9
9
  * - Connection pooling with keepalive
10
10
  * - Session persistence
11
11
  * - Command execution (exec, sudo, su)
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * A comprehensive SSH MCP Server for Claude Code
6
6
  *
7
7
  * Features:
8
- * - Multiple authentication methods (password, key, agent)
8
+ * - Multiple authentication methods (password, key)
9
9
  * - Connection pooling with keepalive
10
10
  * - Session persistence
11
11
  * - Command execution (exec, sudo, su)
@@ -15,13 +15,24 @@
15
15
  */
16
16
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
17
17
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
18
+ import { readFileSync } from 'node:fs';
19
+ import { sessionManager } from './session-manager.js';
18
20
  import { registerConnectionTools, registerExecTools, registerFileTools, registerForwardTools, registerPtyTools, } from './tools/index.js';
19
- const server = new McpServer({ name: 'ssh-mcp-pro', version: '1.2.2' }, { capabilities: { tools: {} } });
21
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
22
+ const server = new McpServer({ name: 'mcp-ssh', version: pkg.version }, { capabilities: { tools: {} } });
20
23
  registerConnectionTools(server);
21
24
  registerExecTools(server);
22
25
  registerFileTools(server);
23
26
  registerPtyTools(server);
24
27
  registerForwardTools(server);
28
+ async function cleanup() {
29
+ try {
30
+ await sessionManager.disconnectAll();
31
+ }
32
+ catch {
33
+ /* 忽略清理错误 */
34
+ }
35
+ }
25
36
  async function main() {
26
37
  // 防止父进程退出后成为孤儿进程持续占用 CPU
27
38
  process.on('uncaughtException', (error) => {
@@ -35,9 +46,25 @@ async function main() {
35
46
  process.exit(1);
36
47
  }
37
48
  });
38
- process.stdin.on('end', () => process.exit(0));
49
+ process.stdin.on('end', async () => {
50
+ await cleanup();
51
+ process.exit(0);
52
+ });
39
53
  process.stdout.on('error', () => process.exit(0));
40
54
  process.stderr.on('error', () => process.exit(0));
55
+ // 优雅退出:SIGINT/SIGTERM 时关闭所有 SSH 会话
56
+ for (const sig of ['SIGINT', 'SIGTERM']) {
57
+ process.on(sig, async () => {
58
+ await cleanup();
59
+ try {
60
+ await server.close();
61
+ }
62
+ catch {
63
+ /* ignore */
64
+ }
65
+ process.exit(0);
66
+ });
67
+ }
41
68
  const transport = new StdioServerTransport();
42
69
  await server.connect(transport);
43
70
  console.error('SSH MCP Pro server started');
@@ -14,6 +14,9 @@ export declare class PtyManager {
14
14
  private sessions;
15
15
  private idCounter;
16
16
  private readonly defaultBufferSize;
17
+ private readonly idleTimeoutMs;
18
+ private idleSweeper;
19
+ constructor();
17
20
  start(deps: PtyDependencies, alias: string, command: string, options?: PtyOptions): Promise<string>;
18
21
  write(ptyId: string, data: string): boolean;
19
22
  read(ptyId: string, options?: {
@@ -30,6 +33,8 @@ export declare class PtyManager {
30
33
  /** 关闭指定 alias 的所有 PTY 会话 */
31
34
  closeByAlias(alias: string): void;
32
35
  list(): PtySessionInfo[];
36
+ private startIdleSweeper;
37
+ private sweepIdle;
33
38
  private getSession;
34
39
  private generateId;
35
40
  /** 从终端仿真器获取当前屏幕内容 */
@@ -9,6 +9,12 @@ export class PtyManager {
9
9
  sessions = new Map();
10
10
  idCounter = 0;
11
11
  defaultBufferSize = 1024 * 1024; // 1MB
12
+ // 默认 idle timeout 1 小时,超时未读的 pty 自动回收
13
+ idleTimeoutMs = Number(process.env.SSH_MCP_PTY_IDLE_TIMEOUT_MS) || 3600_000;
14
+ idleSweeper = null;
15
+ constructor() {
16
+ this.startIdleSweeper();
17
+ }
12
18
  async start(deps, alias, command, options = {}) {
13
19
  const ptyId = this.generateId();
14
20
  const rows = options.rows || 24;
@@ -47,6 +53,13 @@ export class PtyManager {
47
53
  });
48
54
  stream.on('close', () => {
49
55
  ptySession.active = false;
56
+ this.sessions.delete(ptyId);
57
+ try {
58
+ terminal.dispose();
59
+ }
60
+ catch (e) {
61
+ console.warn(`PTY ${ptyId} terminal dispose failed:`, e.message);
62
+ }
50
63
  });
51
64
  stream.on('error', (err) => {
52
65
  ptySession.active = false;
@@ -141,6 +154,28 @@ export class PtyManager {
141
154
  }
142
155
  return result;
143
156
  }
157
+ startIdleSweeper() {
158
+ if (this.idleSweeper) {
159
+ return;
160
+ }
161
+ // 每 5 分钟扫一次,关闭超过 idleTimeout 未读的 pty
162
+ this.idleSweeper = setInterval(() => this.sweepIdle(), 5 * 60_000);
163
+ if (typeof this.idleSweeper.unref === 'function') {
164
+ this.idleSweeper.unref();
165
+ }
166
+ }
167
+ sweepIdle() {
168
+ const now = Date.now();
169
+ for (const [id, session] of this.sessions) {
170
+ if (!session.active) {
171
+ continue;
172
+ }
173
+ if (now - session.lastReadAt > this.idleTimeoutMs) {
174
+ console.warn(`[mcp-ssh] PTY ${id} (alias=${session.alias}, command=${session.command}) idle ${Math.round((now - session.lastReadAt) / 1000)}s > ${Math.round(this.idleTimeoutMs / 1000)}s, auto-closing`);
175
+ this.close(id);
176
+ }
177
+ }
178
+ }
144
179
  getSession(ptyId) {
145
180
  const session = this.sessions.get(ptyId);
146
181
  if (!session) {
@@ -154,8 +189,10 @@ export class PtyManager {
154
189
  /** 从终端仿真器获取当前屏幕内容 */
155
190
  getScreenContent(terminal) {
156
191
  const buffer = terminal.buffer.active;
192
+ const start = buffer.viewportY;
193
+ const end = start + terminal.rows;
157
194
  const lines = [];
158
- for (let i = 0; i < terminal.rows; i++) {
195
+ for (let i = start; i < end; i++) {
159
196
  const line = buffer.getLine(i);
160
197
  if (line) {
161
198
  lines.push(line.translateToString(true));
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 路径与文件安全校验
3
+ *
4
+ * 限制 privateKeyPath / configPath 必须位于白名单目录下,
5
+ * 加文件大小上限避免任意大文件被读取,
6
+ * 错误消息脱敏避免 PEM 细节泄露
7
+ */
8
+ /**
9
+ * 校验私钥文件路径在白名单内,且大小不超限
10
+ *
11
+ * 双重校验:原路径(path.resolve 后)和真实路径(realpath 解析所有 symlink 后)都必须在白名单内,
12
+ * 防止"白名单内的 symlink 指向白名单外文件"绕过
13
+ */
14
+ export declare function validateKeyFile(p: string): void;
15
+ /**
16
+ * 校验 SSH config 文件路径在白名单内,且大小不超限
17
+ *
18
+ * 同 validateKeyFile:原路径 + realpath 都必须在白名单
19
+ */
20
+ export declare function validateConfigFile(p: string): void;
21
+ /**
22
+ * 脱敏 ssh2 keyParser 错误,避免 PEM 文件 cipher/kdf 字段被泄露
23
+ */
24
+ export declare function sanitizeKeyError(message: string): string;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 路径与文件安全校验
3
+ *
4
+ * 限制 privateKeyPath / configPath 必须位于白名单目录下,
5
+ * 加文件大小上限避免任意大文件被读取,
6
+ * 错误消息脱敏避免 PEM 细节泄露
7
+ */
8
+ import * as fs from 'fs';
9
+ import * as os from 'os';
10
+ import * as path from 'path';
11
+ const MAX_KEY_FILE_SIZE = 64 * 1024; // 私钥实际不会超过 64KB
12
+ const MAX_CONFIG_FILE_SIZE = 1024 * 1024; // SSH config 上限 1MB
13
+ function getAllowedDirs() {
14
+ const base = [path.resolve(os.homedir(), '.ssh'), '/etc/ssh'];
15
+ const env = process.env.SSH_MCP_ALLOWED_KEY_DIRS?.split(path.delimiter)
16
+ .map((d) => d.trim())
17
+ .filter(Boolean) ?? [];
18
+ return [...base, ...env.map((d) => path.resolve(d))];
19
+ }
20
+ function isUnderAllowedDir(resolved) {
21
+ const allowed = getAllowedDirs();
22
+ const ok = allowed.some((dir) => resolved === dir || resolved.startsWith(dir + path.sep));
23
+ return { ok, allowed };
24
+ }
25
+ /**
26
+ * 校验私钥文件路径在白名单内,且大小不超限
27
+ *
28
+ * 双重校验:原路径(path.resolve 后)和真实路径(realpath 解析所有 symlink 后)都必须在白名单内,
29
+ * 防止"白名单内的 symlink 指向白名单外文件"绕过
30
+ */
31
+ export function validateKeyFile(p) {
32
+ const resolved = path.resolve(p);
33
+ if (!isUnderAllowedDir(resolved).ok) {
34
+ const { allowed } = isUnderAllowedDir(resolved);
35
+ throw new Error(`Invalid private key path: must be under ${allowed.join(' or ')} ` +
36
+ `(set SSH_MCP_ALLOWED_KEY_DIRS to extend, separated by '${path.delimiter}')`);
37
+ }
38
+ const real = fs.realpathSync(resolved);
39
+ if (!isUnderAllowedDir(real).ok) {
40
+ throw new Error(`Invalid private key path: symlink target falls outside the whitelist`);
41
+ }
42
+ const stats = fs.statSync(real);
43
+ if (stats.size > MAX_KEY_FILE_SIZE) {
44
+ throw new Error(`Private key file too large: ${stats.size} bytes (max ${MAX_KEY_FILE_SIZE})`);
45
+ }
46
+ }
47
+ /**
48
+ * 校验 SSH config 文件路径在白名单内,且大小不超限
49
+ *
50
+ * 同 validateKeyFile:原路径 + realpath 都必须在白名单
51
+ */
52
+ export function validateConfigFile(p) {
53
+ const resolved = path.resolve(p);
54
+ if (!isUnderAllowedDir(resolved).ok) {
55
+ const { allowed } = isUnderAllowedDir(resolved);
56
+ throw new Error(`Invalid config path: must be under ${allowed.join(' or ')} ` +
57
+ `(set SSH_MCP_ALLOWED_KEY_DIRS to extend, separated by '${path.delimiter}')`);
58
+ }
59
+ const real = fs.realpathSync(resolved);
60
+ if (!isUnderAllowedDir(real).ok) {
61
+ throw new Error(`Invalid config path: symlink target falls outside the whitelist`);
62
+ }
63
+ const stats = fs.statSync(real);
64
+ if (stats.size > MAX_CONFIG_FILE_SIZE) {
65
+ throw new Error(`SSH config file too large: ${stats.size} bytes (max ${MAX_CONFIG_FILE_SIZE})`);
66
+ }
67
+ }
68
+ /**
69
+ * 脱敏 ssh2 keyParser 错误,避免 PEM 文件 cipher/kdf 字段被泄露
70
+ */
71
+ export function sanitizeKeyError(message) {
72
+ const lower = message.toLowerCase();
73
+ if (lower.includes('private key') ||
74
+ lower.includes('pem') ||
75
+ lower.includes('encrypted') ||
76
+ lower.includes('passphrase') ||
77
+ lower.includes('cipher')) {
78
+ return 'Invalid private key file';
79
+ }
80
+ return message;
81
+ }
@@ -17,9 +17,13 @@ interface SSHSession {
17
17
  reconnectAttempts: number;
18
18
  connected: boolean;
19
19
  manualClose: boolean;
20
+ /** 当前正在等待的重连定时器,disconnect 时需要清除以防 zombie 重连 */
21
+ reconnectTimer?: NodeJS.Timeout;
20
22
  }
21
23
  export declare class SessionManager {
22
24
  private sessions;
25
+ /** per-alias connect 进行中的 Promise,防止并发 connect 同一 alias 时重复建连 */
26
+ private connectInFlight;
23
27
  private readonly ptyManager;
24
28
  private readonly forwardManager;
25
29
  private readonly persistPath;
@@ -31,7 +35,7 @@ export declare class SessionManager {
31
35
  private reconnectDelay;
32
36
  constructor(persistPath?: string);
33
37
  /**
34
- * 建立 SSH 连接
38
+ * 建立 SSH 连接(per-alias mutex,防止并发 connect 同一 alias 重复建连)
35
39
  */
36
40
  connect(config: SSHConnectionConfig): Promise<string>;
37
41
  /**
@@ -42,6 +46,8 @@ export declare class SessionManager {
42
46
  * 断开连接
43
47
  */
44
48
  disconnect(alias: string): boolean;
49
+ /** 断开所有活跃会话(SIGINT/SIGTERM 时调用) */
50
+ disconnectAll(): Promise<void>;
45
51
  /**
46
52
  * 获取会话
47
53
  */
@@ -57,16 +63,18 @@ export declare class SessionManager {
57
63
  /**
58
64
  * 以其他用户身份执行命令
59
65
  *
60
- * options.loadProfile 控制是否加载用户的 shell 配置(默认 true)。
66
+ * options.loadProfile 控制是否加载用户的 shell 配置(默认 true)
61
67
  * su -c 创建非交互式 shell,不会自动执行 rc 文件,
62
- * 但大多数用户的环境变量设置在 rc 文件中,因此默认加载。
63
- * 支持 bash(.bashrc)、zsh(.zshrc) 及其他 shell(.profile)。
68
+ * 但大多数用户的环境变量设置在 rc 文件中,因此默认加载
69
+ * 支持 bash(.bashrc)、zsh(.zshrc) 及其他 shell(.profile)
64
70
  */
65
71
  execAsUser(alias: string, command: string, targetUser: string, options?: ExecOptions & {
66
72
  loadProfile?: boolean;
67
73
  }): Promise<ExecResult>;
68
74
  /**
69
75
  * 使用 sudo 执行命令
76
+ *
77
+ * 通过 stdin 传递密码,避免密码出现在进程列表和 audit 日志中
70
78
  */
71
79
  execSudo(alias: string, command: string, sudoPassword?: string, options?: ExecOptions): Promise<ExecResult>;
72
80
  /**
@@ -87,10 +95,14 @@ export declare class SessionManager {
87
95
  ptyResize(ptyId: string, rows: number, cols: number): boolean;
88
96
  ptyClose(ptyId: string): boolean;
89
97
  ptyList(): PtySessionInfo[];
90
- forwardLocal(alias: string, localPort: number, remoteHost: string, remotePort: number, localHost?: string): Promise<string>;
98
+ forwardLocal(alias: string, localPort: number, remoteHost: string, remotePort: number, localHost?: string): Promise<{
99
+ forwardId: string;
100
+ localPort: number;
101
+ }>;
91
102
  forwardRemote(alias: string, remotePort: number, localHost: string, localPort: number, remoteHost?: string): Promise<string>;
92
103
  forwardClose(forwardId: string): boolean;
93
104
  forwardList(): PortForwardInfo[];
105
+ private connectInternal;
94
106
  /**
95
107
  * 执行带 PTY 的命令,返回原始 stream(供 PtyManager 使用)
96
108
  */
@@ -117,7 +129,8 @@ export declare class SessionManager {
117
129
  */
118
130
  private diagnoseConnectionError;
119
131
  /**
120
- * 转义 shell 参数(使用单引号方式)
132
+ * 转义 shell 参数(使用单引号方式,防止命令注入)
133
+ * 委托给 tools/utils.ts 的共享实现
121
134
  */
122
135
  private escapeShellArg;
123
136
  /**
@@ -138,7 +151,7 @@ export declare class SessionManager {
138
151
  */
139
152
  private getLoadProfileCommand;
140
153
  /**
141
- * 持久化会话信息
154
+ * 持久化会话信息(异步非阻塞,避免阻塞事件循环)
142
155
  */
143
156
  private persistSessions;
144
157
  }