mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Increased the maximum length of incoming NetworkPackages from 1KB to 512KB
BUG: 343417
This commit is contained in:
@@ -158,13 +158,11 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
|
|
||||||
final NioSocketConnector connector = new NioSocketConnector();
|
final NioSocketConnector connector = new NioSocketConnector();
|
||||||
connector.setHandler(tcpHandler);
|
connector.setHandler(tcpHandler);
|
||||||
//TextLineCodecFactory will split incoming data delimited by the given string
|
|
||||||
connector.getFilterChain().addLast("codec",
|
|
||||||
new ProtocolCodecFilter(
|
|
||||||
new TextLineCodecFactory(Charset.defaultCharset(), LineDelimiter.UNIX, LineDelimiter.UNIX)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
connector.getSessionConfig().setKeepAlive(true);
|
connector.getSessionConfig().setKeepAlive(true);
|
||||||
|
//TextLineCodecFactory will buffer incoming data and emit a message very time it finds a \n
|
||||||
|
TextLineCodecFactory textLineFactory = new TextLineCodecFactory(Charset.defaultCharset(), LineDelimiter.UNIX, LineDelimiter.UNIX);
|
||||||
|
textLineFactory.setDecoderMaxLineLength(512*1024); //Allow to receive up to 512kb of data
|
||||||
|
tcpAcceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(textLineFactory));
|
||||||
|
|
||||||
int tcpPort = identityPackage.getInt("tcpPort",port);
|
int tcpPort = identityPackage.getInt("tcpPort",port);
|
||||||
ConnectFuture future = connector.connect(new InetSocketAddress(address.getAddress(), tcpPort));
|
ConnectFuture future = connector.connect(new InetSocketAddress(address.getAddress(), tcpPort));
|
||||||
@@ -235,17 +233,16 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
tcpAcceptor.getSessionConfig().setKeepAlive(true);
|
tcpAcceptor.getSessionConfig().setKeepAlive(true);
|
||||||
tcpAcceptor.getSessionConfig().setReuseAddress(true);
|
tcpAcceptor.getSessionConfig().setReuseAddress(true);
|
||||||
tcpAcceptor.setCloseOnDeactivation(false);
|
tcpAcceptor.setCloseOnDeactivation(false);
|
||||||
//TextLineCodecFactory will split incoming data delimited by the given string
|
//TextLineCodecFactory will buffer incoming data and emit a message very time it finds a \n
|
||||||
tcpAcceptor.getFilterChain().addLast("codec",
|
TextLineCodecFactory textLineFactory = new TextLineCodecFactory(Charset.defaultCharset(), LineDelimiter.UNIX, LineDelimiter.UNIX);
|
||||||
new ProtocolCodecFilter(
|
textLineFactory.setDecoderMaxLineLength(512*1024); //Allow to receive up to 512kb of data
|
||||||
new TextLineCodecFactory(Charset.defaultCharset(), LineDelimiter.UNIX, LineDelimiter.UNIX)
|
tcpAcceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(textLineFactory));
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
udpAcceptor = new NioDatagramAcceptor();
|
udpAcceptor = new NioDatagramAcceptor();
|
||||||
udpAcceptor.getSessionConfig().setReuseAddress(true); //Share port if existing
|
udpAcceptor.getSessionConfig().setReuseAddress(true); //Share port if existing
|
||||||
//TextLineCodecFactory will split incoming data delimited by the given string
|
//TextLineCodecFactory will buffer incoming data and emit a message very time it finds a \n
|
||||||
|
//This one will have the default MaxLineLength of 1KB
|
||||||
udpAcceptor.getFilterChain().addLast("codec",
|
udpAcceptor.getFilterChain().addLast("codec",
|
||||||
new ProtocolCodecFilter(
|
new ProtocolCodecFilter(
|
||||||
new TextLineCodecFactory(Charset.defaultCharset(), LineDelimiter.UNIX, LineDelimiter.UNIX)
|
new TextLineCodecFactory(Charset.defaultCharset(), LineDelimiter.UNIX, LineDelimiter.UNIX)
|
||||||
|
Reference in New Issue
Block a user