You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2021/02/17 13:23:08 UTC

[openmeetings] branch master updated: [OPENMEETINGS-2551] max upload download size is limited

This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new afe26c9  [OPENMEETINGS-2551] max upload download size is limited
afe26c9 is described below

commit afe26c950b127776f2dfe920abff41a584874de8
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Wed Feb 17 20:22:54 2021 +0700

    [OPENMEETINGS-2551] max upload download size is limited
---
 .../main/java/org/apache/openmeetings/web/room/raw-nettest.js |  6 ++----
 .../org/apache/openmeetings/webservice/NetTestWebService.java | 11 ++++++++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/raw-nettest.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/raw-nettest.js
index 5ae15a4..d2d111d 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/raw-nettest.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/raw-nettest.js
@@ -73,7 +73,7 @@ var NetTest = (function() {
 	function __netTest(params, callback) {
 		let tail = '';
 		if (params.size) {
-			params.curSize = params.multiplier * (params.curSize ? params.curSize : params.size);
+			params.curSize = params.size + (params.curSize || 0);
 			tail = '&size=' + params.curSize;
 		}
 		setTimeout(() => {
@@ -133,7 +133,6 @@ var NetTest = (function() {
 							url: '?type=upload'
 							, mode: 'upload'
 							, size: 512 * KB
-							, multiplier: 2
 							, delay: DELAY
 						}
 						, maxTime: LIMIT
@@ -149,8 +148,7 @@ var NetTest = (function() {
 						action: __netTest
 						, params: {
 							url: '?type=download'
-							, size: 2 * MB
-							, multiplier: 2
+							, size: 1 * MB
 							, delay: DELAY
 						}
 						, maxTime: LIMIT
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/NetTestWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/NetTestWebService.java
index b95c25c..de8831e 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/NetTestWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/NetTestWebService.java
@@ -55,7 +55,8 @@ public class NetTestWebService {
 
 	private static final int PING_PACKET_SIZE = 64;
 	private static final int JITTER_PACKET_SIZE = 1024;
-	private static final int MAX_UPLOAD_SIZE = 16 * 1024 * 1024;
+	private static final int MAX_DOWNLOAD_SIZE = 5 * 1024 * 1024;
+	private static final int MAX_UPLOAD_SIZE = 5 * 512 * 1024;
 	public static final AtomicInteger CLIENT_COUNT = new AtomicInteger();
 	private static int maxClients = 100;
 
@@ -90,6 +91,9 @@ public class NetTestWebService {
 				size = inSize;
 				break;
 		}
+		if (size > MAX_DOWNLOAD_SIZE) {
+			return Response.status(Status.BAD_REQUEST).build();
+		}
 		return Response.ok()
 				.type(MediaType.APPLICATION_OCTET_STREAM).entity(new InputStream() {
 					int pos = 0;
@@ -124,9 +128,9 @@ public class NetTestWebService {
 	@POST
 	@Consumes(MediaType.APPLICATION_OCTET_STREAM)
 	@Path("/")
-	public void upload(@QueryParam("size") int size, InputStream stream) throws IOException {
+	public int upload(@QueryParam("size") int size, InputStream stream) throws IOException {
 		if (size > MAX_UPLOAD_SIZE) {
-			return;
+			return -1;
 		}
 		CLIENT_COUNT.incrementAndGet();
 		byte[] b = new byte[1024];
@@ -140,6 +144,7 @@ public class NetTestWebService {
 		} finally {
 			CLIENT_COUNT.decrementAndGet();
 		}
+		return totalCount;
 	}
 
 	public static TestType getTypeByString(String typeString) {