mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Automatically upgrade non-SSL nodes to SSL if they fail (#1757)
* Automatically upgrade non-SSL nodes to SSL if they fail * another ssl catch * [skip ci] pr fixes
This commit is contained in:
parent
eff6616981
commit
765ae87712
1 changed files with 22 additions and 1 deletions
|
@ -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<String, dynamic>;
|
||||
return !(resBody['result']['offline'] as bool);
|
||||
} catch (_) {
|
||||
|
|
Loading…
Reference in a new issue