mirror of
https://git.krews.org/morningstar/nitrowebsockets-for-ms
synced 2024-11-26 08:50:51 +01:00
Merge branch 'info-for-origin-mismatch' into 'master'
Add logging for mismatched Websocket Origin See merge request nitro/ms-websockets!1
This commit is contained in:
commit
1a4b8ef8f9
@ -6,12 +6,18 @@ import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageCodec;
|
||||
import io.netty.handler.codec.http.websocketx.*;
|
||||
import org.krews.plugin.nitro.main;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
public class WebSocketCodec extends MessageToMessageCodec<WebSocketFrame, ByteBuf> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketCodec.class);
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
out.add(new BinaryWebSocketFrame(in).retain());
|
||||
@ -53,6 +59,10 @@ public class WebSocketCodec extends MessageToMessageCodec<WebSocketFrame, ByteBu
|
||||
if(origin.equals(entry)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(Emulator.getConfig().getBoolean("debug.mode")) {
|
||||
LOGGER.info("Origin not allowed: " + origin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user