Merge pull request #290 from torhve/sslerror
Better user feedback for connection problems
This commit is contained in:
commit
91bca211ee
2 changed files with 24 additions and 6 deletions
|
@ -45,6 +45,9 @@
|
||||||
<div class="alert alert-danger" ng-show="sslError">
|
<div class="alert alert-danger" ng-show="sslError">
|
||||||
<strong>Secure connection error</strong> A secure connection with the WeeChat relay could not be initiated. This is most likely because your browser does not trust your relay's certificate. Please read the encryption instructions below!
|
<strong>Secure connection error</strong> A secure connection with the WeeChat relay could not be initiated. This is most likely because your browser does not trust your relay's certificate. Please read the encryption instructions below!
|
||||||
</div>
|
</div>
|
||||||
|
<div class="alert alert-danger" ng-show="securityError">
|
||||||
|
<strong>Secure connection error</strong> Unable to connect to unencrypted relay when your are connecting to Glowing Bear over HTTPS. Please use an encrypted relay or load the page without using HTTPS.
|
||||||
|
</div>
|
||||||
<div class="panel-group" id="accordion">
|
<div class="panel-group" id="accordion">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
@ -82,7 +85,7 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-lg btn-primary" ng-click="connect()">Connect <i class="glyphicon glyphicon-chevron-right"></i></button>
|
<button class="btn btn-lg btn-primary" ng-click="connect()">{{ connectbutton }} <i class="glyphicon glyphicon-chevron-right"></i></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -242,6 +242,7 @@ function($rootScope,
|
||||||
var connect = function (host, port, passwd, ssl, noCompression) {
|
var connect = function (host, port, passwd, ssl, noCompression) {
|
||||||
var proto = ssl ? 'wss' : 'ws';
|
var proto = ssl ? 'wss' : 'ws';
|
||||||
var url = proto + "://" + host + ":" + port + "/weechat";
|
var url = proto + "://" + host + ":" + port + "/weechat";
|
||||||
|
$log.debug('Connecting to URL: ', url);
|
||||||
|
|
||||||
var onopen = function () {
|
var onopen = function () {
|
||||||
|
|
||||||
|
@ -344,9 +345,8 @@ function($rootScope,
|
||||||
$log.info("Disconnected from relay");
|
$log.info("Disconnected from relay");
|
||||||
failCallbacks('disconnection');
|
failCallbacks('disconnection');
|
||||||
$rootScope.connected = false;
|
$rootScope.connected = false;
|
||||||
if ($rootScope.waseverconnected) {
|
|
||||||
$rootScope.$emit('relayDisconnect');
|
$rootScope.$emit('relayDisconnect');
|
||||||
} else if (ssl && evt.code === 1006) {
|
if (ssl && evt.code === 1006) {
|
||||||
// A password error doesn't trigger onerror, but certificate issues do. Check time of last error.
|
// A password error doesn't trigger onerror, but certificate issues do. Check time of last error.
|
||||||
if (typeof $rootScope.lastError !== "undefined" && (Date.now() - $rootScope.lastError) < 1000) {
|
if (typeof $rootScope.lastError !== "undefined" && (Date.now() - $rootScope.lastError) < 1000) {
|
||||||
// abnormal disconnect by client, most likely ssl error
|
// abnormal disconnect by client, most likely ssl error
|
||||||
|
@ -375,6 +375,7 @@ function($rootScope,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
ngWebsockets.connect(url,
|
ngWebsockets.connect(url,
|
||||||
protocol,
|
protocol,
|
||||||
{
|
{
|
||||||
|
@ -384,6 +385,13 @@ function($rootScope,
|
||||||
'onmessage': onmessage,
|
'onmessage': onmessage,
|
||||||
'onerror': onerror
|
'onerror': onerror
|
||||||
});
|
});
|
||||||
|
} catch(e) {
|
||||||
|
$log.debug("Websocket caught DOMException:", e);
|
||||||
|
$rootScope.lastError = Date.now();
|
||||||
|
$rootScope.errorMessage = true;
|
||||||
|
$rootScope.securityError = true;
|
||||||
|
$rootScope.$emit('relayDisconnect');
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -636,7 +644,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeBuffer = models.getActiveBuffer();
|
var activeBuffer = models.getActiveBuffer();
|
||||||
|
if (activeBuffer) {
|
||||||
$rootScope.pageTitle = activeBuffer.shortName + ' | ' + activeBuffer.title;
|
$rootScope.pageTitle = activeBuffer.shortName + ' | ' + activeBuffer.title;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.updateFavico = function() {
|
$scope.updateFavico = function() {
|
||||||
|
@ -728,7 +738,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
// Disabled it until it's fully investigated and fixed
|
// Disabled it until it's fully investigated and fixed
|
||||||
//models.reinitialize();
|
//models.reinitialize();
|
||||||
$rootScope.$emit('notificationChanged');
|
$rootScope.$emit('notificationChanged');
|
||||||
|
$scope.connectbutton = 'Connect';
|
||||||
});
|
});
|
||||||
|
$scope.connectbutton = 'Connect';
|
||||||
|
|
||||||
$scope.showSidebar = true;
|
$scope.showSidebar = true;
|
||||||
|
|
||||||
|
@ -969,10 +981,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$scope.connect = function() {
|
$scope.connect = function() {
|
||||||
$scope.requestNotificationPermission();
|
$scope.requestNotificationPermission();
|
||||||
$rootScope.sslError = false;
|
$rootScope.sslError = false;
|
||||||
|
$rootScope.securityError = false;
|
||||||
$rootScope.errorMessage = false;
|
$rootScope.errorMessage = false;
|
||||||
|
$scope.connectbutton = 'Connecting ...';
|
||||||
connection.connect($scope.host, $scope.port, $scope.password, $scope.ssl);
|
connection.connect($scope.host, $scope.port, $scope.password, $scope.ssl);
|
||||||
};
|
};
|
||||||
$scope.disconnect = function() {
|
$scope.disconnect = function() {
|
||||||
|
$scope.connectbutton = 'Connect';
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
};
|
};
|
||||||
$scope.install = function() {
|
$scope.install = function() {
|
||||||
|
|
Loading…
Reference in a new issue