From 2d43d349ab67f48896c1c40e736de6cbcb1cb227 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Tue, 2 Dec 2014 13:22:26 +0000 Subject: [PATCH] add more invalid ports --- .../src/net/i2p/router/transport/TransportUtil.java | 13 ++++++++++++- .../net/i2p/router/transport/udp/UDPEndpoint.java | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/TransportUtil.java b/router/java/src/net/i2p/router/transport/TransportUtil.java index 713ec7612d..ef8a7786fe 100644 --- a/router/java/src/net/i2p/router/transport/TransportUtil.java +++ b/router/java/src/net/i2p/router/transport/TransportUtil.java @@ -173,11 +173,22 @@ public abstract class TransportUtil { /** * Is this a valid port for us or a remote router? * + * ref: http://i2p-projekt.i2p/en/docs/ports + * * @since 0.9.17 moved from logic in individual transports */ public static boolean isValidPort(int port) { + // update log message in UDPEndpoint if you update this list return port >= 1024 && port <= 65535 && - port != 1900; // UPnP SSDP + port != 1900 && // UPnP SSDP + port != 2827 && // BOB + port != 4444 && // HTTP + port != 4445 && // HTTPS + port != 6668 && // IRC + (!(port >= 7650 && port <= 7664)) && // standard I2P range + port != 8998 && // mtn + port != 31000 && // Wrapper + port != 32000; // Wrapper } } diff --git a/router/java/src/net/i2p/router/transport/udp/UDPEndpoint.java b/router/java/src/net/i2p/router/transport/udp/UDPEndpoint.java index 44ddea1437..a1e680182e 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPEndpoint.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPEndpoint.java @@ -113,8 +113,12 @@ class UDPEndpoint implements SocketListener { private DatagramSocket getSocket() { DatagramSocket socket = null; int port = _listenPort; - if (port > 0 && !TransportUtil.isValidPort(port)) - _log.error("Specified UDP port is " + port + ", ports lower than 1024 not recommended"); + if (port > 0 && !TransportUtil.isValidPort(port)) { + _log.error("Specified UDP port " + port + " is not valid, selecting a new port"); + // See isValidPort() for list + _log.error("Invalid ports are: 0-1023, 1900, 2827, 4444, 4445, 6668, 7650-7664, 8998, 31000, 32000, 65536+"); + port = -1; + } for (int i = 0; i < MAX_PORT_RETRIES; i++) { if (port <= 0) { -- GitLab