disable http and ws when navigating AriaNg via https
This commit is contained in:
parent
ccac9d82a2
commit
71e1d5ce37
|
@ -179,9 +179,12 @@ Minutes=分
|
|||
Seconds=秒
|
||||
Milliseconds=毫秒
|
||||
Http=Http
|
||||
Http (Disabled)=Http (禁用)
|
||||
Https=Https
|
||||
WebSocket=WebSocket
|
||||
WebSocket (Disabled)=WebSocket (禁用)
|
||||
WebSocket (Security)=WebSocket (安全)
|
||||
Http and WebSocket would be disabled when navigating AriaNg via Https.=使用 Https 访问 AriaNg 时,Http 和 WebSocket 将被禁用.
|
||||
POST=POST
|
||||
GET=GET
|
||||
Disabled=禁用
|
||||
|
|
|
@ -179,9 +179,12 @@ Minutes=分
|
|||
Seconds=秒
|
||||
Milliseconds=毫秒
|
||||
Http=Http
|
||||
Http (Disabled)=Http (禁用)
|
||||
Https=Https
|
||||
WebSocket=WebSocket
|
||||
WebSocket (Disabled)=WebSocket (禁用)
|
||||
WebSocket (Security)=WebSocket (安全)
|
||||
Http and WebSocket would be disabled when navigating AriaNg via Https.=使用 Https 訪問 AriaNg 時,Http 和 WebSocket 將被禁用.
|
||||
POST=POST
|
||||
GET=GET
|
||||
Disabled=禁用
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
languageFileExtension: '.txt',
|
||||
defaultLanguage: 'en',
|
||||
defaultHost: 'localhost',
|
||||
defaultSecureProtocol: 'https',
|
||||
globalStatStorageCapacity: 120,
|
||||
taskStatStorageCapacity: 300,
|
||||
lazySaveTimeout: 500,
|
||||
|
|
|
@ -183,9 +183,12 @@
|
|||
'Seconds': 'Seconds',
|
||||
'Milliseconds': 'Milliseconds',
|
||||
'Http': 'Http',
|
||||
'Http (Disabled)': 'Http (Disabled)',
|
||||
'Https': 'Https',
|
||||
'WebSocket': 'WebSocket',
|
||||
'WebSocket (Disabled)': 'WebSocket (Disabled)',
|
||||
'WebSocket (Security)': 'WebSocket (Security)',
|
||||
'Http and WebSocket would be disabled when navigating AriaNg via Https.': 'Http and WebSocket would be disabled when navigating AriaNg via Https.',
|
||||
'POST': 'POST',
|
||||
'GET': 'GET',
|
||||
'Disabled': 'Disabled',
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),
|
||||
trueFalseOptions: [{name: 'True', value: true}, {name: 'False', value: false}],
|
||||
showRpcSecret: false,
|
||||
isInsecureProtocolDisabled: ariaNgSettingService.isInsecureProtocolDisabled(),
|
||||
settings: ariaNgSettingService.getAllOptions(),
|
||||
sessionSettings: ariaNgSettingService.getAllSessionOptions(),
|
||||
rpcSettings: ariaNgSettingService.getAllRpcSettings()
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
}
|
||||
};
|
||||
|
||||
var isInsecureProtocolDisabled = function () {
|
||||
var protocol = $location.protocol();
|
||||
|
||||
return protocol === 'https';
|
||||
};
|
||||
|
||||
var getLanguageNameFromAlias = function (alias) {
|
||||
for (var langName in ariaNgLanguages) {
|
||||
if (!ariaNgLanguages.hasOwnProperty(langName)) {
|
||||
|
@ -100,6 +106,20 @@
|
|||
options = angular.extend({}, ariaNgDefaultOptions);
|
||||
options.language = getDefaultLanguage();
|
||||
|
||||
if (!options.rpcHost) {
|
||||
initRpcSettingWithDefaultHostAndProtocol(options);
|
||||
}
|
||||
|
||||
if (angular.isArray(options.extendRpcServers)) {
|
||||
for (var i = 0; i < options.extendRpcServers.length; i++) {
|
||||
var rpcSetting = options.extendRpcServers[i];
|
||||
|
||||
if (!rpcSetting.rpcHost) {
|
||||
initRpcSettingWithDefaultHostAndProtocol(rpcSetting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setOptions(options);
|
||||
fireFirstVisitEvent();
|
||||
}
|
||||
|
@ -129,6 +149,14 @@
|
|||
setOptions(options);
|
||||
};
|
||||
|
||||
var initRpcSettingWithDefaultHostAndProtocol = function (setting) {
|
||||
setting.rpcHost = getDefaultRpcHost();
|
||||
|
||||
if (isInsecureProtocolDisabled()) {
|
||||
setting.protocol = ariaNgConstants.defaultSecureProtocol;
|
||||
}
|
||||
};
|
||||
|
||||
var cloneRpcSetting = function (setting) {
|
||||
return {
|
||||
rpcAlias: setting.rpcAlias,
|
||||
|
@ -144,7 +172,8 @@
|
|||
var createNewRpcSetting = function () {
|
||||
var setting = cloneRpcSetting(ariaNgDefaultOptions);
|
||||
setting.rpcId = ariaNgCommonService.generateUniqueId();
|
||||
setting.rpcHost = getDefaultRpcHost();
|
||||
|
||||
initRpcSettingWithDefaultHostAndProtocol(setting);
|
||||
|
||||
return setting;
|
||||
};
|
||||
|
@ -153,10 +182,6 @@
|
|||
getAllOptions: function () {
|
||||
var options = angular.extend({}, ariaNgDefaultOptions, getOptions());
|
||||
|
||||
if (!options.rpcHost) {
|
||||
options.rpcHost = getDefaultRpcHost();
|
||||
}
|
||||
|
||||
if (options.secret) {
|
||||
options.secret = base64.decode(options.secret);
|
||||
}
|
||||
|
@ -165,10 +190,6 @@
|
|||
for (var i = 0; i < options.extendRpcServers.length; i++) {
|
||||
var rpcSetting = options.extendRpcServers[i];
|
||||
|
||||
if (!rpcSetting.rpcHost) {
|
||||
rpcSetting.rpcHost = getDefaultRpcHost();
|
||||
}
|
||||
|
||||
if (rpcSetting.secret) {
|
||||
rpcSetting.secret = base64.decode(rpcSetting.secret);
|
||||
}
|
||||
|
@ -199,6 +220,9 @@
|
|||
getAllSessionOptions: function () {
|
||||
return angular.copy(sessionSettings);
|
||||
},
|
||||
isInsecureProtocolDisabled: function () {
|
||||
return isInsecureProtocolDisabled();
|
||||
},
|
||||
applyLanguage: function (lang) {
|
||||
if (!ariaNgLanguages[lang]) {
|
||||
return false;
|
||||
|
@ -248,26 +272,21 @@
|
|||
setOption('browserNotification', value);
|
||||
},
|
||||
getCurrentRpcUrl: function () {
|
||||
var protocol = getOption('protocol');
|
||||
var rpcHost = getOption('rpcHost');
|
||||
var rpcPort = getOption('rpcPort');
|
||||
var rpcInterface = getOption('rpcInterface');
|
||||
|
||||
if (!rpcHost) {
|
||||
rpcHost = getDefaultRpcHost();
|
||||
}
|
||||
var options = getOptions();
|
||||
var protocol = options.protocol;
|
||||
var rpcHost = options.rpcHost;
|
||||
var rpcPort = options.rpcPort;
|
||||
var rpcInterface = options.rpcInterface;
|
||||
|
||||
return protocol + '://' + rpcHost + ':' + rpcPort + '/' + rpcInterface;
|
||||
},
|
||||
getCurrentRpcProtocol: function () {
|
||||
return getOption('protocol');
|
||||
},
|
||||
getCurrentRpcHttpMethod: function () {
|
||||
return getOption('httpMethod');
|
||||
},
|
||||
isCurrentRpcUseWebSocket: function (protocol) {
|
||||
if (!protocol) {
|
||||
protocol = this.getCurrentRpcProtocol();
|
||||
var options = getOptions();
|
||||
protocol = options.protocol;
|
||||
}
|
||||
|
||||
return protocol === 'ws' || protocol === 'wss';
|
||||
|
|
|
@ -171,12 +171,14 @@
|
|||
<div class="setting-key setting-key-without-desc col-sm-4">
|
||||
<span translate>Aria2 RPC Protocol</span>
|
||||
<span class="asterisk">*</span>
|
||||
<i class="icon-primary fa fa-question-circle" ng-tooltip-container="body" ng-tooltip-placement="top"
|
||||
ng-tooltip="{{'Http and WebSocket would be disabled when navigating AriaNg via Https.' | translate}}"></i>
|
||||
</div>
|
||||
<div class="setting-value col-sm-8">
|
||||
<select class="form-control" style="width: 100%;" ng-model="setting.protocol" ng-change="updateRpcSetting(setting, 'protocol')">
|
||||
<option value="http" translate>Http</option>
|
||||
<option value="http" ng-disabled="::(context.isInsecureProtocolDisabled)" ng-bind="('Http' + (context.isInsecureProtocolDisabled ? ' (Disabled)' : '')) | translate">Http</option>
|
||||
<option value="https" translate>Https</option>
|
||||
<option value="ws" translate>WebSocket</option>
|
||||
<option value="ws" ng-disabled="::(context.isInsecureProtocolDisabled)" ng-bind="('WebSocket' + (context.isInsecureProtocolDisabled ? ' (Disabled)' : '')) | translate">WebSocket</option>
|
||||
<option value="wss" translate>WebSocket (Security)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
Reference in a new issue