diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index 4d4c4e8d3bd5996f972cb489d6b1d320e571dc90..294d27df6088ad77d99edba45f629553f4ad2bcf 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -317,6 +317,11 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
return server != null && server.endsWith(".onion");
}
+ public boolean isDirectToOnion() {
+ final var hostname = Strings.nullToEmpty(this.hostname).trim();
+ return isOnion() && (hostname.isEmpty() || hostname.endsWith(".onion"));
+ }
+
public int getPort() {
return this.port;
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 4c64ce11fc3d5b17cfc1d80aa1af83f930b12986..0fbdf57f80c1d88712ddd05f83cc304dc61f9307 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -304,8 +304,9 @@ public class XmppConnection implements Runnable {
Socket localSocket;
shouldAuthenticate = !account.isOptionSet(Account.OPTION_REGISTER);
this.changeStatus(Account.State.CONNECTING);
- final boolean useTor = mXmppConnectionService.useTorToConnect() || account.isOnion();
+ final boolean useTorSetting = mXmppConnectionService.useTorToConnect();
final boolean extended = mXmppConnectionService.showExtendedConnectionOptions();
+ final boolean useTor = useTorSetting || account.isOnion();
// TODO collapse Tor usage into normal connection code path
if (useTor) {
final var seeOtherHost = this.seeOtherHostResolverResult;
@@ -323,7 +324,15 @@ public class XmppConnection implements Runnable {
Resolver.fromHardCoded(
account.getServer(), Resolver.XMPP_PORT_STARTTLS));
} else {
- viaTor = Iterables.getOnlyElement(Resolver.fromHardCoded(hostname, port));
+ if (useTorSetting || extended) {
+ // if the hostname configuration is showing we can take it
+ viaTor = Iterables.getOnlyElement(Resolver.fromHardCoded(hostname, port));
+ } else {
+ viaTor =
+ Iterables.getOnlyElement(
+ Resolver.fromHardCoded(
+ account.getServer(), Resolver.XMPP_PORT_STARTTLS));
+ }
this.verifiedHostname = hostname;
}
@@ -1567,7 +1576,9 @@ public class XmppConnection implements Runnable {
}
private boolean isSecure() {
- return features.encryptionEnabled || Config.ALLOW_NON_TLS_CONNECTIONS || account.isOnion();
+ return (features.encryptionEnabled && this.socket instanceof SSLSocket)
+ || Config.ALLOW_NON_TLS_CONNECTIONS
+ || account.isDirectToOnion();
}
private void authenticate(final SaslMechanism.Version version) throws IOException {
diff --git a/src/main/res/menu/message_context.xml b/src/main/res/menu/message_context.xml
index aa572bcdf712b74c8732a15197269e80b48ac352..2d0d118de2110521deca41d42cfac05acf8511cd 100644
--- a/src/main/res/menu/message_context.xml
+++ b/src/main/res/menu/message_context.xml
@@ -55,9 +55,10 @@
android:id="@+id/send_again"
android:title="@string/send_again"
android:visible="false" />
-
+ android:visible="false" />