Don't overwrite server name in open ID info when doing SRV lookups

Otherwise we don't end up asking for a token for matrix.org, we ask on behalf of matrix.org:8448
This commit is contained in:
turt2live 2017-09-08 21:12:26 -06:00
parent 0b37269014
commit aa075ef9ca

View File

@ -28,16 +28,17 @@ class MatrixLiteClient {
} }
_do(method, endpoint, qs = null, body = null) { _do(method, endpoint, qs = null, body = null) {
var serverName = this._openId.matrix_server_name;
// HACK: We have to wrap the dns promise in a Bluebird promise just to make sure it works // HACK: We have to wrap the dns promise in a Bluebird promise just to make sure it works
var dnsPromise = dns.resolveSrv("_matrix._tcp." + this._openId.matrix_server_name); var dnsPromise = dns.resolveSrv("_matrix._tcp." + serverName);
return Promise.resolve(dnsPromise).then(records => { return Promise.resolve(dnsPromise).then(records => {
if (records && records.length > 0) if (records && records.length > 0)
this._openId.matrix_server_name = records[0].name + ":" + records[0].port; serverName = records[0].name + ":" + records[0].port;
}, err => { }, err => {
log.warn("MatrixLiteClient", "Failed to lookup SRV for " + this._openId.matrix_server_name + " - assuming none available."); log.warn("MatrixLiteClient", "Failed to lookup SRV for " + serverName + " - assuming none available.");
log.warn("MatrixLiteClient", err); log.warn("MatrixLiteClient", err);
}).then(() => { }).then(() => {
var url = "https://" + this._openId.matrix_server_name + endpoint; var url = "https://" + serverName + endpoint;
log.verbose("MatrixLiteClient", "Performing request: " + url); log.verbose("MatrixLiteClient", "Performing request: " + url);