Loading mail/protocols/smtp/src/main/java/com/fsck/k9/mail/transport/smtp/SmtpTransport.java +4 −5 Original line number Diff line number Diff line Loading @@ -301,15 +301,14 @@ public class SmtpTransport extends Transport { } } @VisibleForTesting protected String buildHostnameToReport() { private String buildHostnameToReport() { InetAddress localAddress = socket.getLocalAddress(); String ipAddr = localAddress.getHostAddress(); // we use local ip statically for privacy reasons, see https://github.com/k9mail/k-9/pull/3798 if (localAddress instanceof Inet6Address) { return "[IPv6:" + ipAddr + "]"; return "[IPv6:::1]"; } else { return "[" + ipAddr + "]"; return "[127.0.0.1]"; } } Loading mail/protocols/smtp/src/test/java/com/fsck/k9/mail/transport/smtp/SmtpTransportTest.java +5 −26 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ import com.fsck.k9.mail.helpers.TestTrustedSocketFactory; import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.oauth.OAuth2TokenProvider; import com.fsck.k9.mail.ssl.TrustedSocketFactory; import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.transport.mockServer.MockSmtpServer; import org.junit.Before; import org.junit.Test; Loading @@ -43,7 +42,6 @@ public class SmtpTransportTest { private TrustedSocketFactory socketFactory; private OAuth2TokenProvider oAuth2TokenProvider; private StoreConfig storeConfig = mock(StoreConfig.class); @Before Loading @@ -62,7 +60,7 @@ public class SmtpTransportTest { server.output("250-localhost Hello client.localhost"); server.output("250 OK"); SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE, null, "[127.0.0.1]"); null); transport.open(); Loading Loading @@ -861,18 +859,16 @@ public class SmtpTransportTest { } private SmtpTransport startServerAndCreateSmtpTransportWithoutPassword(MockSmtpServer server) throws Exception { return startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE, null, "[127.0.0.1]"); return startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE, null); } private SmtpTransport startServerAndCreateSmtpTransport(MockSmtpServer server, AuthType authenticationType, ConnectionSecurity connectionSecurity) throws Exception { return startServerAndCreateSmtpTransport(server, authenticationType, connectionSecurity, PASSWORD, "[127.0.0.1]"); return startServerAndCreateSmtpTransport(server, authenticationType, connectionSecurity, PASSWORD); } private SmtpTransport startServerAndCreateSmtpTransport(MockSmtpServer server, AuthType authenticationType, ConnectionSecurity connectionSecurity, String password, String injectedHostname) ConnectionSecurity connectionSecurity, String password) throws Exception { server.start(); Loading @@ -888,7 +884,7 @@ public class SmtpTransportTest { password, CLIENT_CERTIFICATE_ALIAS); return new TestSmtpTransport(serverSettings, socketFactory, oAuth2TokenProvider, injectedHostname); return new SmtpTransport(serverSettings, socketFactory, oAuth2TokenProvider); } private TestMessageBuilder getDefaultMessageBuilder() { Loading Loading @@ -925,21 +921,4 @@ public class SmtpTransportTest { return server; } static class TestSmtpTransport extends SmtpTransport { private final String injectedHostname; TestSmtpTransport(ServerSettings serverSettings, TrustedSocketFactory trustedSocketFactory, OAuth2TokenProvider oAuth2TokenProvider, String injectedHostname) { super(serverSettings, trustedSocketFactory, oAuth2TokenProvider); this.injectedHostname = injectedHostname; } @Override protected String buildHostnameToReport() { return injectedHostname; } } } Loading
mail/protocols/smtp/src/main/java/com/fsck/k9/mail/transport/smtp/SmtpTransport.java +4 −5 Original line number Diff line number Diff line Loading @@ -301,15 +301,14 @@ public class SmtpTransport extends Transport { } } @VisibleForTesting protected String buildHostnameToReport() { private String buildHostnameToReport() { InetAddress localAddress = socket.getLocalAddress(); String ipAddr = localAddress.getHostAddress(); // we use local ip statically for privacy reasons, see https://github.com/k9mail/k-9/pull/3798 if (localAddress instanceof Inet6Address) { return "[IPv6:" + ipAddr + "]"; return "[IPv6:::1]"; } else { return "[" + ipAddr + "]"; return "[127.0.0.1]"; } } Loading
mail/protocols/smtp/src/test/java/com/fsck/k9/mail/transport/smtp/SmtpTransportTest.java +5 −26 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ import com.fsck.k9.mail.helpers.TestTrustedSocketFactory; import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.oauth.OAuth2TokenProvider; import com.fsck.k9.mail.ssl.TrustedSocketFactory; import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.transport.mockServer.MockSmtpServer; import org.junit.Before; import org.junit.Test; Loading @@ -43,7 +42,6 @@ public class SmtpTransportTest { private TrustedSocketFactory socketFactory; private OAuth2TokenProvider oAuth2TokenProvider; private StoreConfig storeConfig = mock(StoreConfig.class); @Before Loading @@ -62,7 +60,7 @@ public class SmtpTransportTest { server.output("250-localhost Hello client.localhost"); server.output("250 OK"); SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE, null, "[127.0.0.1]"); null); transport.open(); Loading Loading @@ -861,18 +859,16 @@ public class SmtpTransportTest { } private SmtpTransport startServerAndCreateSmtpTransportWithoutPassword(MockSmtpServer server) throws Exception { return startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE, null, "[127.0.0.1]"); return startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE, null); } private SmtpTransport startServerAndCreateSmtpTransport(MockSmtpServer server, AuthType authenticationType, ConnectionSecurity connectionSecurity) throws Exception { return startServerAndCreateSmtpTransport(server, authenticationType, connectionSecurity, PASSWORD, "[127.0.0.1]"); return startServerAndCreateSmtpTransport(server, authenticationType, connectionSecurity, PASSWORD); } private SmtpTransport startServerAndCreateSmtpTransport(MockSmtpServer server, AuthType authenticationType, ConnectionSecurity connectionSecurity, String password, String injectedHostname) ConnectionSecurity connectionSecurity, String password) throws Exception { server.start(); Loading @@ -888,7 +884,7 @@ public class SmtpTransportTest { password, CLIENT_CERTIFICATE_ALIAS); return new TestSmtpTransport(serverSettings, socketFactory, oAuth2TokenProvider, injectedHostname); return new SmtpTransport(serverSettings, socketFactory, oAuth2TokenProvider); } private TestMessageBuilder getDefaultMessageBuilder() { Loading Loading @@ -925,21 +921,4 @@ public class SmtpTransportTest { return server; } static class TestSmtpTransport extends SmtpTransport { private final String injectedHostname; TestSmtpTransport(ServerSettings serverSettings, TrustedSocketFactory trustedSocketFactory, OAuth2TokenProvider oAuth2TokenProvider, String injectedHostname) { super(serverSettings, trustedSocketFactory, oAuth2TokenProvider); this.injectedHostname = injectedHostname; } @Override protected String buildHostnameToReport() { return injectedHostname; } } }