Skip to content

Commit bf3f8ff

Browse files
authored
Merge pull request #129 from jumpserver/dev
v4.10.8-lts
2 parents 4257a40 + ad06d9b commit bf3f8ff

16 files changed

Lines changed: 125 additions & 10 deletions

File tree

backend/framework/src/main/java/org/jumpserver/chen/framework/session/Session.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
import java.nio.file.Path;
1414
import java.sql.Connection;
1515
import java.sql.SQLException;
16+
import java.time.LocalDateTime;
1617
import java.util.Locale;
1718
import java.util.Map;
1819

1920
public interface Session {
2021

22+
void refreshLastActiveTime();
23+
24+
LocalDateTime getLastActiveTime();
25+
2126
boolean canUpload();
2227

2328
boolean canDownload();

backend/framework/src/main/java/org/jumpserver/chen/framework/session/controller/impl/BaseController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jumpserver.chen.framework.session.controller.impl;
22

33
import lombok.extern.slf4j.Slf4j;
4+
import org.jumpserver.chen.framework.session.SessionManager;
45
import org.jumpserver.chen.framework.session.controller.Controller;
56
import org.jumpserver.chen.framework.session.controller.dialog.Dialog;
67
import org.jumpserver.chen.framework.session.controller.message.Message;
@@ -40,11 +41,20 @@ public void handlePacket(Packet packet) {
4041
case "dialog_event":
4142
this.onDialogEvent((String) packet.getData());
4243
break;
44+
case "input_active":
45+
this.refreshLastActiveTime();
46+
break;
4347
default:
4448
break;
4549
}
4650
}
4751

52+
53+
private void refreshLastActiveTime() {
54+
var session = SessionManager.getCurrentSession();
55+
session.refreshLastActiveTime();
56+
}
57+
4858
@Override
4959
public void sendFile(String fileKey) {
5060
this.packetIO.sendPacket("download", fileKey);

backend/framework/src/main/java/org/jumpserver/chen/framework/session/impl/BaseSession.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.nio.file.Paths;
2222
import java.sql.Connection;
2323
import java.sql.SQLException;
24+
import java.time.LocalDateTime;
2425
import java.util.Locale;
2526
import java.util.Map;
2627
import java.util.concurrent.ConcurrentHashMap;
@@ -57,13 +58,21 @@ public class BaseSession implements Session {
5758

5859
private boolean enableAutoComplete = true;
5960

61+
@Getter
62+
private LocalDateTime lastActiveTime;
63+
6064

6165
public BaseSession(Datasource datasource, String remoteAddr) {
6266
this.datasource = datasource;
6367
this.remoteAddr = remoteAddr;
6468
}
6569

6670

71+
@Override
72+
public void refreshLastActiveTime() {
73+
this.lastActiveTime = LocalDateTime.now();
74+
}
75+
6776
@Override
6877
public boolean canUpload() {
6978
return true;

backend/framework/src/main/java/org/jumpserver/chen/framework/session/impl/JMSSession.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public class JMSSession extends BaseSession {
5151
private final long expireTime;
5252

5353

54-
private LocalDateTime lastActiveTime;
55-
5654
private LocalDateTime maxSessionEndTime;
5755
private int maxSessionEndHours;
5856
private LocalDateTime dynamicEndTime;
@@ -205,7 +203,7 @@ private void recordLifecycle(ServiceOuterClass.SessionLifecycleLogRequest.EventT
205203
}
206204

207205
private void startWaitIdleTime() {
208-
this.lastActiveTime = LocalDateTime.now();
206+
this.refreshLastActiveTime();
209207

210208
var token = SessionManager.getContextToken();
211209

@@ -224,7 +222,7 @@ private void startWaitIdleTime() {
224222
return;
225223
}
226224

227-
if (Math.abs(Duration.between(LocalDateTime.now(), this.lastActiveTime).toMinutes()) > this.maxIdleTimeDelta) {
225+
if (Math.abs(Duration.between(LocalDateTime.now(), this.getLastActiveTime()).toMinutes()) > this.maxIdleTimeDelta) {
228226
this.close("OverMaxIdleTimeError", "idle_disconnect", this.maxIdleTimeDelta);
229227
return;
230228
}
@@ -310,7 +308,7 @@ private void closeGateway() {
310308
@Override
311309
public SQLQueryResult withAudit(String command, QueryAuditFunction queryAuditFunction) throws SQLException, CommandRejectException {
312310
synchronized (this) {
313-
this.lastActiveTime = LocalDateTime.now();
311+
this.refreshLastActiveTime();
314312
}
315313
if (this.locked) {
316314
throw new CommandRejectException(MessageUtils.get("SessionLockedError"));

backend/modules/src/main/java/org.jumpserver.chen.modules/base/ssl/SSLCertManager.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jumpserver.chen.modules.base.ssl;
22

33
import lombok.Setter;
4+
import org.apache.commons.lang3.StringUtils;
45

56
import java.io.File;
67
import java.io.FileWriter;
@@ -27,6 +28,10 @@ public class SSLCertManager {
2728

2829
// 获取 CA 证书的路径
2930
public String getCaCertPath() throws IOException {
31+
if (StringUtils.isEmpty(caCert)) {
32+
return null;
33+
}
34+
3035
if (caCertFile == null) {
3136
caCertFile = createTempFile("ca-cert", caCert);
3237
}
@@ -35,6 +40,10 @@ public String getCaCertPath() throws IOException {
3540

3641
// 获取客户端私钥的路径,并将 PEM 格式的私钥转换为 DER 格式
3742
public String getClientCertKeyPath() throws Exception {
43+
if (StringUtils.isEmpty(clientCertKey)) {
44+
return null;
45+
}
46+
3847
if (clientCertKeyFile == null) {
3948
// 检查 clientCertKey 是否是 PEM 格式并转换为 DER
4049
clientCertKeyFile = createTempFile("client-cert-key", convertPEMToDER(clientCertKey));
@@ -44,6 +53,11 @@ public String getClientCertKeyPath() throws Exception {
4453

4554
// 获取客户端证书的路径
4655
public String getClientCertPath() throws IOException {
56+
57+
if (StringUtils.isEmpty(clientCert)) {
58+
return null;
59+
}
60+
4761
if (clientCertFile == null) {
4862
clientCertFile = createTempFile("client-cert", clientCert);
4963
}

backend/modules/src/main/java/org.jumpserver.chen.modules/postgresql/PostgresqlConnectionManager.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jumpserver.chen.modules.postgresql;
22

3+
import org.apache.commons.lang3.StringUtils;
34
import org.jumpserver.chen.framework.datasource.Datasource;
45
import org.jumpserver.chen.framework.datasource.base.BaseConnectionManager;
56
import org.jumpserver.chen.framework.datasource.entity.DBConnectInfo;
@@ -48,11 +49,24 @@ protected void setSSLProps(Properties props) {
4849

4950

5051
try {
52+
var sslCaCertPath = sslManager.getCaCertPath();
53+
var sslClientCertPath = sslManager.getClientCertPath();
54+
var sslClientCertKeyPath = sslManager.getClientCertKeyPath();
55+
5156
props.setProperty("ssl", "true");
5257
props.setProperty("sslmode", sslMode);
53-
props.setProperty("sslrootcert", sslManager.getCaCertPath());
54-
props.setProperty("sslcert", sslManager.getClientCertPath());
55-
props.setProperty("sslkey", sslManager.getClientCertKeyPath());
58+
59+
if (StringUtils.isNotEmpty(sslCaCertPath)) {
60+
props.setProperty("sslrootcert", sslManager.getCaCertPath());
61+
}
62+
63+
if (StringUtils.isNotEmpty(sslClientCertPath)) {
64+
props.setProperty("sslcert", sslManager.getClientCertPath());
65+
}
66+
67+
if (StringUtils.isNotEmpty(sslClientCertKeyPath)) {
68+
props.setProperty("sslkey", sslManager.getClientCertKeyPath());
69+
}
5670
} catch (Exception e) {
5771
throw new RuntimeException(e);
5872
}

backend/web/src/main/java/org/jumpserver/chen/web/config/WebSocketConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.jumpserver.chen.framework.ws.ConsoleWebSocketHandler;
44
import org.jumpserver.chen.framework.ws.DBConsoleWebsocketHandler;
55
import org.jumpserver.chen.framework.ws.SessionWebSocketHandler;
6+
import org.springframework.context.annotation.Bean;
67
import org.springframework.context.annotation.Configuration;
78
import org.springframework.http.server.ServerHttpRequest;
89
import org.springframework.http.server.ServerHttpResponse;
@@ -11,13 +12,27 @@
1112
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
1213
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
1314
import org.springframework.web.socket.server.HandshakeInterceptor;
15+
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
1416

1517
import java.util.Map;
1618
import java.util.Objects;
1719

1820
@Configuration
1921
@EnableWebSocket
2022
public class WebSocketConfig implements WebSocketConfigurer {
23+
24+
25+
@Bean
26+
public ServletServerContainerFactoryBean createWebSocketContainer() {
27+
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
28+
container.setMaxTextMessageBufferSize(20 * 1024 * 1024);
29+
container.setMaxBinaryMessageBufferSize(20 * 1024 * 1024);
30+
// 可选:异步发送超时
31+
// container.setAsyncSendTimeout(20_000L);
32+
return container;
33+
}
34+
35+
2136
@Override
2237
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
2338
registry

frontend/src/bus/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Vue from 'vue'
2+
3+
export const bus = new Vue()

frontend/src/components/Controller/index.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
:show-close="dialogOptions.showClose"
66
:close-on-click-modal="false"
77
:visible.sync="dialogVisible"
8+
:modal="false"
89
>
910
<div
1011
v-if="dialogOptions.body && dialogOptions.bodyType==='html'"
1112
v-html="dialogOptions.body"
1213
/>
13-
<div v-else v-text="dialogOptions.body" />
14+
<div v-else v-text="dialogOptions.body"/>
1415

1516
<span v-if="dialogOptions && dialogOptions.buttons" slot="footer" class="dialog-footer" style="text-align: center">
1617
<el-button
@@ -26,6 +27,7 @@
2627
import { getUrlParams } from '@/utils/field'
2728
import { LunaEvent, MESSAGES } from '@/utils/luna'
2829
import { index } from '@/request'
30+
import { bus } from '@/bus'
2931
3032
export default {
3133
name: 'Controller',
@@ -48,8 +50,20 @@ export default {
4850
this.lunaEvent.init()
4951
this.auth()
5052
this.handleRenewLunaSession()
53+
this.handleInputActive()
5154
},
5255
methods: {
56+
handleInputActive() {
57+
bus.$on('input-active', () => {
58+
this.lunaEvent.sendEventToLuna(MESSAGES.INPUT_ACTIVE)
59+
})
60+
61+
this.lunaEvent.setInputActiveHandler(() => {
62+
console.log('receive other window input active message')
63+
this.sendPacket('input_active')
64+
})
65+
},
66+
5367
handleRenewLunaSession() {
5468
const lunaEvent = this.lunaEvent
5569

frontend/src/components/Main/Explore/DataView/ExportDataDialog.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
v-if="visible"
44
:title="$tc('ExportData')"
55
:visible.sync="iVisible"
6+
:modal="false"
67
width="40%"
78
>
89
<el-form ref="form" :model="form" label-width="80px">

0 commit comments

Comments
 (0)