From 0f2affd414e4ccff504ddfbe96025d327ca5a21c Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Tue, 28 Oct 2014 14:00:37 +0000
Subject: [PATCH] SSU: Don't publish direct info if introducers are required

---
 .../net/i2p/router/transport/udp/UDPTransport.java | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java
index 1affe6bf11..b9cf45f0d2 100644
--- a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java
+++ b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java
@@ -1848,19 +1848,20 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
             return null;
         
         OrderedProperties options = new OrderedProperties(); 
-        boolean directIncluded = false;
+        boolean directIncluded;
         // DNS name assumed IPv4
         boolean isIPv6 = host != null && host.contains(":");
-        if (allowDirectUDP() && port > 0 && host != null) {
-            // TODO don't add these if we have (or require?) introducers
+        boolean introducersRequired = (!isIPv6) && introducersRequired();
+        if (!introducersRequired && allowDirectUDP() && port > 0 && host != null) {
             options.setProperty(UDPAddress.PROP_PORT, String.valueOf(port));
             options.setProperty(UDPAddress.PROP_HOST, host);
             directIncluded = true;
+        } else {
+            directIncluded = false;
         }
         
-        boolean introducersRequired = (!isIPv6) && introducersRequired();
         boolean introducersIncluded = false;
-        if (introducersRequired || !directIncluded) {
+        if (introducersRequired) {
             // FIXME intro manager doesn't sort introducers, so
             // deepEquals() below can fail even with same introducers.
             // Only a problem when we have very very few peers to pick from.
@@ -1872,9 +1873,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
                 _introducersSelectedOn = _context.clock().now();
                 introducersIncluded = true;
             } else {
-                // FIXME
-                // maybe we should fail to publish an address at all in this case?
-                // YES that would be better
                 if (_log.shouldLog(Log.WARN))
                     _log.warn("Direct? " + directIncluded + " reqd? " + introducersRequired +
                               " no introducers");
-- 
GitLab