Ignore packets that don't come from private networks

This commit is contained in:
Albert Vaca Cintora
2025-10-31 20:47:02 +01:00
parent 726e75a3e3
commit a4d7bec978

View File

@@ -132,6 +132,12 @@ public class LanLinkProvider extends BaseLinkProvider {
private void tcpPacketReceived(Socket socket) throws IOException {
InetAddress address = socket.getInetAddress();
if (!address.isSiteLocalAddress() && !address.isLinkLocalAddress()) {
Log.i("LanLinkProvider", "Discarding UDP packet from a non-local IP");
return;
}
if (rateLimitByIp(address)) {
Log.i("LanLinkProvider", "Discarding second TCP packet from the same ip " + address + " received too quickly");
return;
@@ -209,6 +215,11 @@ public class LanLinkProvider extends BaseLinkProvider {
final InetAddress address = packet.getAddress();
if (!address.isSiteLocalAddress() && !address.isLinkLocalAddress()) {
Log.i("LanLinkProvider", "Discarding UDP packet from a non-local IP");
return;
}
if (rateLimitByIp(address)) {
Log.i("LanLinkProvider", "Discarding second UDP packet from the same ip " + address + " received too quickly");
return;