mirror of
https://git.krews.org/morningstar/nitrowebsockets-for-ms
synced 2024-11-22 23:10:52 +01:00
Add logging for mismatched Websocket Origin
This commit is contained in:
parent
f9d94197d5
commit
ea20237166
@ -6,12 +6,18 @@ import io.netty.channel.ChannelFutureListener;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToMessageCodec;
|
import io.netty.handler.codec.MessageToMessageCodec;
|
||||||
import io.netty.handler.codec.http.websocketx.*;
|
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.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class WebSocketCodec extends MessageToMessageCodec<WebSocketFrame, ByteBuf> {
|
public class WebSocketCodec extends MessageToMessageCodec<WebSocketFrame, ByteBuf> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketCodec.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void encode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void encode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
out.add(new BinaryWebSocketFrame(in).retain());
|
out.add(new BinaryWebSocketFrame(in).retain());
|
||||||
@ -53,6 +59,7 @@ public class WebSocketCodec extends MessageToMessageCodec<WebSocketFrame, ByteBu
|
|||||||
if(origin.equals(entry)) return true;
|
if(origin.equals(entry)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOGGER.info("Origin not allowed: " + origin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user