Fix connecting to wildcard addresses. (#6167)
This commit is contained in:
parent
d53028d0a8
commit
0209c6e0ff
@ -101,13 +101,7 @@ export default class SecureApi extends Api {
|
|||||||
return 'dapps.parity';
|
return 'dapps.parity';
|
||||||
}
|
}
|
||||||
|
|
||||||
const { host } = this._dappsAddress;
|
return this._dappsAddress.host;
|
||||||
|
|
||||||
if (!host || host === '0.0.0.0') {
|
|
||||||
return window.location.hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
return host;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get isConnecting () {
|
get isConnecting () {
|
||||||
@ -173,6 +167,25 @@ export default class SecureApi extends Api {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves a wildcard address to `window.location.hostname`;
|
||||||
|
*/
|
||||||
|
_resolveHost (url) {
|
||||||
|
const parts = url ? url.split(':') : [];
|
||||||
|
const port = parts[1];
|
||||||
|
let host = parts[0];
|
||||||
|
|
||||||
|
if (!host) {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host === '0.0.0.0') {
|
||||||
|
host = window.location.hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
return port ? `${host}:${port}` : host;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Promise that gets resolved with
|
* Returns a Promise that gets resolved with
|
||||||
* a boolean: `true` if the node is up, `false`
|
* a boolean: `true` if the node is up, `false`
|
||||||
@ -316,8 +329,8 @@ export default class SecureApi extends Api {
|
|||||||
this._uiApi.parity.wsUrl()
|
this._uiApi.parity.wsUrl()
|
||||||
])
|
])
|
||||||
.then(([dappsUrl, wsUrl]) => {
|
.then(([dappsUrl, wsUrl]) => {
|
||||||
this._dappsUrl = dappsUrl;
|
this._dappsUrl = this._resolveHost(dappsUrl);
|
||||||
this._wsUrl = wsUrl;
|
this._wsUrl = this._resolveHost(wsUrl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user