diff --git a/src/langs/it_IT.txt b/src/langs/it_IT.txt index 616af75c..7a014861 100644 --- a/src/langs/it_IT.txt +++ b/src/langs/it_IT.txt @@ -306,7 +306,8 @@ Cannot initialize WebSocket!=Impossibile inizializzare WebSocket! Cannot connect to aria2!=Impossibile connettersi a aria2! Access Denied!=Accesso negato! You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.=Non puoi utilizzare AriaNg perché questo browser non soddisfa i requisiti minimi di archiviazione dati. - +hostProxyPatternName=Modello proxy host +hostProxyPatternDescription=Specificare il modello regex host per il proxy per riga. Se l'host corrisponde al modello, verrà utilizzato il proxy. Esempio: .*\.example\.com|proxy.com:8080 .*\.example\.org|proxy.org:8080 [error] unknown=Errore sconosciuto. operation.timeout=Operazione scaduta. diff --git a/src/langs/zh_Hans.txt b/src/langs/zh_Hans.txt index f12aa0f2..b66b1230 100644 --- a/src/langs/zh_Hans.txt +++ b/src/langs/zh_Hans.txt @@ -306,7 +306,8 @@ Cannot initialize WebSocket!=无法初始化 WebSocket! Cannot connect to aria2!=无法连接到 aria2! Access Denied!=拒绝访问! You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.=您无法使用 AriaNg, 因为这个浏览器不满足数据存储的最低要求. - +hostProxyPatternName=主机代理模式 +hostProxyPatternDescription=为每行代理指定主机正则表达式模式。如果主机与该模式匹配,则将使用代理。示例:.*\.example\.com|proxy.com:8080 .*\.example\.org|proxy.org:8080 [error] unknown=未知错误. operation.timeout=操作超时. diff --git a/src/langs/zh_Hant.txt b/src/langs/zh_Hant.txt index 791534b1..6fa0e139 100644 --- a/src/langs/zh_Hant.txt +++ b/src/langs/zh_Hant.txt @@ -306,7 +306,8 @@ Cannot initialize WebSocket!=無法初始化 WebSocket! Cannot connect to aria2!=無法連線到 aria2! Access Denied!=拒絕訪問! You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.=您無法使用 AriaNg, 因為此瀏覽器不滿足資料儲存的最低要求. - +hostProxyPatternName=主機代理模式 +hostProxyPatternDescription=為每行代理指定主機正則表達式模式。如果主機與該模式匹配,則將使用代理。示例:.*\.example\.com|proxy.com:8080 .*\.example\.org|proxy.org:8080 [error] unknown=不詳錯誤. operation.timeout=操作超時. diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js index 46dbe54f..c165cf3e 100644 --- a/src/scripts/config/defaultLanguage.js +++ b/src/scripts/config/defaultLanguage.js @@ -310,6 +310,8 @@ 'Cannot connect to aria2!': 'Cannot connect to aria2!', 'Access Denied!': 'Access Denied!', 'You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.': 'You cannot use AriaNg because this browser does not meet the minimum requirements for data storage.', + 'hostProxyPatternName': 'Host Proxy Pattern', + 'hostProxyPatternDescription': 'Specify host regex pattern for proxy per line. If the host matches the pattern, the proxy will be used. Example: .*\\.example\\.com|proxy.com:8080 .*\\.example\\.org|proxy.org:8080', 'error': { 'unknown': 'Unknown error occurred.', 'operation.timeout': 'Operation timed out.', diff --git a/src/scripts/controllers/settings-ariang.js b/src/scripts/controllers/settings-ariang.js index 836b23af..8a19b8ef 100644 --- a/src/scripts/controllers/settings-ariang.js +++ b/src/scripts/controllers/settings-ariang.js @@ -169,6 +169,11 @@ $rootScope.setTheme(value); }; + $scope.setHostProxyPattern = function (value) { + ariaNgSettingService.setHostProxyPattern(value); + $rootScope.setProxyHostPattern(value); + }; + $scope.setDebugMode = function (value) { ariaNgSettingService.setDebugMode(value); }; diff --git a/src/scripts/services/aria2RpcService.js b/src/scripts/services/aria2RpcService.js index 48f79853..5138866c 100644 --- a/src/scripts/services/aria2RpcService.js +++ b/src/scripts/services/aria2RpcService.js @@ -318,6 +318,21 @@ addUri: function (context, returnContextOnly) { var urls = context.task ? context.task.urls : null; var options = buildRequestOptions(context.task ? context.task.options : {}, context); + var proxyRegex= ariaNgSettingService.getHostProxyPattern().trim(); + if (proxyRegex) { + var patterns = proxyRegex.split('\n'); + for (var i = 0; i < patterns.length; i++) { + patterns[i] = patterns[i].trim() + if (patterns[i]) { + var lastIndex = patterns[i].lastIndexOf('|'); + if (lastIndex === -1) continue + var hostRegex = patterns[i].slice(0, lastIndex).trim(); + var httpProxy = patterns[i].slice(lastIndex + 1).trim(); + if (urls[0].match(hostRegex)) options['all-proxy'] = httpProxy + + } + } + } return invoke(buildRequestContext('addUri', context, urls, options), !!returnContextOnly); }, diff --git a/src/scripts/services/ariaNgSettingService.js b/src/scripts/services/ariaNgSettingService.js index 9eb3eef1..5f05325a 100644 --- a/src/scripts/services/ariaNgSettingService.js +++ b/src/scripts/services/ariaNgSettingService.js @@ -360,6 +360,12 @@ setTitle: function (value) { setOption('title', value); }, + getHostProxyPattern: function () { + return getOption('hostProxyPattern'); + }, + setHostProxyPattern: function (value) { + setOption('hostProxyPattern', value); + }, getBrowserNotification: function () { return getOption('browserNotification'); }, diff --git a/src/views/settings-ariang.html b/src/views/settings-ariang.html index a00ac51f..b33ee6b8 100644 --- a/src/views/settings-ariang.html +++ b/src/views/settings-ariang.html @@ -83,6 +83,18 @@ [Preview] +