Skip to content

Commit 66c29cc

Browse files
committed
update
1 parent 64dd0ab commit 66c29cc

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>websocket-server</artifactId>
13-
<version>1.0.4</version>
13+
<version>1.0.5</version>
1414
<name>WebsocketServer</name>
1515
<packaging>jar</packaging>
1616

src/main/java/info/unterrainer/websocketserver/WebsocketServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public WebsocketServer wsOauth(String path, WsOauthHandlerBase handler) {
5757
wss.ws(path, ws -> {
5858
ws.onConnect(handler::onConnect);
5959
ws.onMessage(handler::onMessage);
60+
ws.onBinaryMessage(handler::onBinaryMessage);
6061
ws.onClose(handler::onClose);
6162
ws.onError(handler::onError);
6263
});

src/main/java/info/unterrainer/websocketserver/WsHandlerBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package info.unterrainer.websocketserver;
22

3+
import io.javalin.websocket.WsBinaryMessageContext;
34
import io.javalin.websocket.WsCloseContext;
45
import io.javalin.websocket.WsConnectContext;
56
import io.javalin.websocket.WsErrorContext;
@@ -11,6 +12,8 @@ public abstract class WsHandlerBase {
1112

1213
public abstract void onMessage(WsMessageContext ctx) throws Exception;
1314

15+
public abstract void onBinaryMessage(WsBinaryMessageContext ctx) throws Exception;
16+
1417
public abstract void onClose(WsCloseContext ctx) throws Exception;
1518

1619
public abstract void onError(WsErrorContext ctx) throws Exception;

src/main/java/info/unterrainer/websocketserver/WsOauthHandlerBase.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.eclipse.jetty.websocket.api.Session;
99

1010
import info.unterrainer.oauthtokenmanager.OauthTokenManager;
11+
import io.javalin.websocket.WsBinaryMessageContext;
1112
import io.javalin.websocket.WsCloseContext;
1213
import io.javalin.websocket.WsConnectContext;
1314
import io.javalin.websocket.WsErrorContext;
@@ -98,6 +99,17 @@ public void onMessage(WsMessageContext ctx) throws Exception {
9899
}
99100
}
100101

102+
@Override
103+
public void onBinaryMessage(WsBinaryMessageContext ctx) throws Exception {
104+
log.debug("Received binary message from [{}]: [{}] bytes", ctx.session.getRemoteAddress(), ctx.data().length);
105+
if (isQuarantined(ctx.session)) {
106+
log.warn("Invalid Message from quarantined client [{}]. Disconnecting.", ctx.session.getRemoteAddress());
107+
removeClient(ctx.session);
108+
ctx.session.close();
109+
return;
110+
}
111+
}
112+
101113
@Override
102114
public void onClose(WsCloseContext ctx) throws Exception {
103115
log.debug("Disconnected client: [{}]", ctx.session.getRemoteAddress());

0 commit comments

Comments
 (0)