Merge pull request 'Check if given node URL has https so we can append https for get_info call' (#120) from mrdeveloper/feather:node-check-for-https into master

Reviewed-on: https://git.wownero.com/feather/feather/pulls/120
Reviewed-by: dsc <dsc@noreply.gitgud.wownero.nl>
This commit is contained in:
dsc 2020-10-26 15:36:36 +00:00
commit 6279591d1b

View file

@ -25,6 +25,9 @@ struct FeatherNode {
FeatherNode(QString _address, unsigned int height, bool online) : height(height), online(online){ FeatherNode(QString _address, unsigned int height, bool online) : height(height), online(online){
// wonky ipv4/host parsing, should be fine(tm)(c). // wonky ipv4/host parsing, should be fine(tm)(c).
if(_address.isEmpty()) return; if(_address.isEmpty()) return;
if(_address.contains("https://")) {
this->isHttps = true;
}
_address = _address.replace("https://", ""); _address = _address.replace("https://", "");
_address = _address.replace("http://", ""); _address = _address.replace("http://", "");
if(_address.contains("@")){ // authentication, user/pass if(_address.contains("@")){ // authentication, user/pass
@ -56,6 +59,7 @@ struct FeatherNode {
bool tor = false; bool tor = false;
bool isConnecting = false; bool isConnecting = false;
bool isActive = false; bool isActive = false;
bool isHttps = false;
QString generateFull() { QString generateFull() {
QString auth; QString auth;
@ -65,7 +69,7 @@ struct FeatherNode {
} }
QString as_url() { QString as_url() {
return QString("http://%1/get_info").arg(this->full); return QString("%1://%2/get_info").arg(this->isHttps ? "https": "http",this->full);
} }
bool operator == (const FeatherNode &other) const { bool operator == (const FeatherNode &other) const {