You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/12/28 02:12:05 UTC

[GitHub] [james-project] chibenwa commented on a diff in pull request #1361: JAMES-3869 SPF mailet: exclude private networks in addition to 127.0.…

chibenwa commented on code in PR #1361:
URL: https://github.com/apache/james-project/pull/1361#discussion_r1058015327


##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java:
##########
@@ -50,32 +58,52 @@
  * &lt;mailet match="All" class="SPF"&gt;
  *   &lt;addHeader&gt;true&lt;/addHeader&gt;
  *   &lt;debug&gt;false&lt;/debug&gt;
+ *   &lt;ignoreNetworks&gt;127.0.0.0/8&lt;/ignoreNetworks&gt;
  * &lt;/mailet&gt;
  * </pre>
  */
 @Experimental
 public class SPF extends GenericMailet {
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SPF.class);
 
+    private boolean debug = false;
     private boolean addHeader = false;
     private org.apache.james.jspf.impl.SPF spf;
     private static final AttributeName EXPLANATION_ATTRIBUTE = AttributeName.of("org.apache.james.transport.mailets.spf.explanation");
     private static final AttributeName RESULT_ATTRIBUTE = AttributeName.of("org.apache.james.transport.mailets.spf.result");
+    private static final String privateNetworks = "127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/16, 172.17.0.0/16, 172.18.0.0/16, 172.19.0.0/16, 172.20.0.0/16, 172.21.0.0/16, 172.22.0.0/16, 172.23.0.0/16, 172.24.0.0/16, 172.25.0.0/16, 172.26.0.0/16, 172.27.0.0/16, 172.28.0.0/16, 172.29.0.0/16, 172.30.0.0/16, 172.31.0.0/16";
+
+    private final DNSService dnsService;
+    private NetMatcher netMatcher;
+
+    @Inject
+    public SPF(DNSService dnsService) {
+        this.dnsService = dnsService;
+    }
 
     @Override
     public void init() {
+        debug = Boolean.parseBoolean(getInitParameter("debug", "false"));
         addHeader = Boolean.parseBoolean(getInitParameter("addHeader", "false"));
-        SPFLoggerAdapter logger = new SPFLoggerAdapter(Boolean.parseBoolean(getInitParameter("debug", "false")));
+        spf = new DefaultSPF(new SPFLoggerAdapter(debug));
+
+        Collection<String> ignoredNetworks = Splitter.on(',')
+            .trimResults()
+            .omitEmptyStrings()
+            .splitToList(getInitParameter("ignoreNetworks", privateNetworks));

Review Comment:
   ignoredNetworks ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org