diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index 1094b6402..18d2ffc44 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -203,9 +203,30 @@ class Node extends HiveObject with Keyable { headers: {'Content-Type': 'application/json'}, body: json.encode(body), ); - client.close(); + if (( + response.body.contains("400 Bad Request") // Some other generic error + || response.body.contains("plain HTTP request was sent to HTTPS port") // Cloudflare + || response.headers["location"] != null // Generic reverse proxy + || response.body.contains("301 Moved Permanently") // Poorly configured generic reverse proxy + ) && !(useSSL??false) + ) { + + final oldUseSSL = useSSL; + useSSL = true; + try { + final ret = await requestMoneroNode(); + if (ret == true) { + await save(); + return ret; + } + useSSL = oldUseSSL; + } catch (e) { + useSSL = oldUseSSL; + } + } + final resBody = json.decode(response.body) as Map; return !(resBody['result']['offline'] as bool); } catch (_) {