mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 11:54:07 +00:00
android: improve proxy errors (#4489)
This commit is contained in:
+57
-14
@@ -1837,23 +1837,27 @@ object ChatController {
|
||||
r is CR.ChatCmdError && r.chatError is ChatError.ChatErrorAgent
|
||||
&& r.chatError.agentError is AgentErrorType.SMP
|
||||
&& r.chatError.agentError.smpErr is SMPErrorType.PROXY ->
|
||||
proxyErrorAlert(r.chatError.agentError.smpErr.proxyErr, r.chatError.agentError.serverAddress)
|
||||
smpProxyErrorAlert(r.chatError.agentError.smpErr.proxyErr, r.chatError.agentError.serverAddress)
|
||||
r is CR.ChatCmdError && r.chatError is ChatError.ChatErrorAgent
|
||||
&& r.chatError.agentError is AgentErrorType.PROXY
|
||||
&& r.chatError.agentError.proxyErr is ProxyClientError.ProxyProtocolError
|
||||
&& r.chatError.agentError.proxyErr.protocolErr is SMPErrorType.PROXY ->
|
||||
proxyErrorAlert(r.chatError.agentError.proxyErr.protocolErr.proxyErr, r.chatError.agentError.proxyServer)
|
||||
proxyDestinationErrorAlert(
|
||||
r.chatError.agentError.proxyErr.protocolErr.proxyErr,
|
||||
r.chatError.agentError.proxyServer,
|
||||
r.chatError.agentError.relayServer
|
||||
)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun proxyErrorAlert(pe: ProxyError, srvAddr: String): Boolean {
|
||||
private fun smpProxyErrorAlert(pe: ProxyError, srvAddr: String): Boolean {
|
||||
return when {
|
||||
pe is ProxyError.BROKER
|
||||
&& pe.brokerErr is BrokerErrorType.TIMEOUT -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
generalGetString(MR.strings.please_try_later)
|
||||
String.format(generalGetString(MR.strings.smp_proxy_error_connecting), serverHostname(srvAddr))
|
||||
)
|
||||
true
|
||||
}
|
||||
@@ -1861,14 +1865,7 @@ object ChatController {
|
||||
&& pe.brokerErr is BrokerErrorType.NETWORK -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
generalGetString(MR.strings.please_try_later)
|
||||
)
|
||||
true
|
||||
}
|
||||
pe is ProxyError.NO_SESSION -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
generalGetString(MR.strings.please_try_later)
|
||||
String.format(generalGetString(MR.strings.smp_proxy_error_connecting), serverHostname(srvAddr))
|
||||
)
|
||||
true
|
||||
}
|
||||
@@ -1876,7 +1873,7 @@ object ChatController {
|
||||
&& pe.brokerErr is BrokerErrorType.HOST -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.network_error_broker_host_desc), serverHostname(srvAddr))
|
||||
String.format(generalGetString(MR.strings.smp_proxy_error_broker_host), serverHostname(srvAddr))
|
||||
)
|
||||
true
|
||||
}
|
||||
@@ -1885,7 +1882,53 @@ object ChatController {
|
||||
&& pe.brokerErr.transportErr is SMPTransportError.Version -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.proxy_error_broker_version_desc), serverHostname(srvAddr))
|
||||
String.format(generalGetString(MR.strings.smp_proxy_error_broker_version), serverHostname(srvAddr))
|
||||
)
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun proxyDestinationErrorAlert(pe: ProxyError, proxyServer: String, relayServer: String): Boolean {
|
||||
return when {
|
||||
pe is ProxyError.BROKER
|
||||
&& pe.brokerErr is BrokerErrorType.TIMEOUT -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.proxy_destination_error_failed_to_connect), serverHostname(proxyServer), serverHostname(relayServer))
|
||||
)
|
||||
true
|
||||
}
|
||||
pe is ProxyError.BROKER
|
||||
&& pe.brokerErr is BrokerErrorType.NETWORK -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.proxy_destination_error_failed_to_connect), serverHostname(proxyServer), serverHostname(relayServer))
|
||||
)
|
||||
true
|
||||
}
|
||||
pe is ProxyError.NO_SESSION -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.proxy_destination_error_failed_to_connect), serverHostname(proxyServer), serverHostname(relayServer))
|
||||
)
|
||||
true
|
||||
}
|
||||
pe is ProxyError.BROKER
|
||||
&& pe.brokerErr is BrokerErrorType.HOST -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.proxy_destination_error_broker_host), serverHostname(relayServer), serverHostname(proxyServer))
|
||||
)
|
||||
true
|
||||
}
|
||||
pe is ProxyError.BROKER
|
||||
&& pe.brokerErr is BrokerErrorType.TRANSPORT
|
||||
&& pe.brokerErr.transportErr is SMPTransportError.Version -> {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.private_routing_error),
|
||||
String.format(generalGetString(MR.strings.proxy_destination_error_broker_version), serverHostname(relayServer), serverHostname(proxyServer))
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
@@ -115,8 +115,13 @@
|
||||
<string name="network_error_broker_host_desc">Server address is incompatible with network settings: %1$s.</string>
|
||||
<string name="network_error_broker_version_desc">Server version is incompatible with your app: %1$s.</string>
|
||||
<string name="private_routing_error">Private routing error</string>
|
||||
<string name="smp_proxy_error_connecting">Error connecting to forwarding server %1$s. Please try later.</string>
|
||||
<string name="smp_proxy_error_broker_host">Forwarding server address is incompatible with network settings: %1$s.</string>
|
||||
<string name="smp_proxy_error_broker_version">Forwarding server version is incompatible with network settings: %1$s.</string>
|
||||
<string name="proxy_destination_error_failed_to_connect">Forwarding server %1$s failed to connect to destination server %2$s. Please try later.</string>
|
||||
<string name="proxy_destination_error_broker_host">Destination server address of %1$s is incompatible with forwarding server %2$s settings.</string>
|
||||
<string name="proxy_destination_error_broker_version">Destination server version of %1$s is incompatible with forwarding server %2$s.</string>
|
||||
<string name="please_try_later">Please try later.</string>
|
||||
<string name="proxy_error_broker_version_desc">Server version is incompatible with network settings: %1$s.</string>
|
||||
<string name="error_sending_message">Error sending message</string>
|
||||
<string name="error_creating_message">Error creating message</string>
|
||||
<string name="error_loading_details">Error loading details</string>
|
||||
|
||||
Reference in New Issue
Block a user