Skip to content

Commit

Permalink
feat: Add host proxy pattern for global proxy configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
divyam234 committed May 13, 2024
1 parent e92cce8 commit 7405519
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/langs/it_IT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/langs/zh_Hans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=操作超时.
Expand Down
3 changes: 2 additions & 1 deletion src/langs/zh_Hant.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=操作超時.
Expand Down
2 changes: 2 additions & 0 deletions src/scripts/config/defaultLanguage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/controllers/settings-ariang.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
$rootScope.setTheme(value);
};

$scope.setHostProxyPattern = function (value) {
ariaNgSettingService.setHostProxyPattern(value);
$rootScope.setProxyHostPattern(value);
};

$scope.setDebugMode = function (value) {
ariaNgSettingService.setDebugMode(value);
};
Expand Down
15 changes: 15 additions & 0 deletions src/scripts/services/aria2RpcService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/services/ariaNgSettingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
Expand Down
12 changes: 12 additions & 0 deletions src/views/settings-ariang.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@
<em>[<span translate>Preview</span>] <span ng-bind="context.titlePreview"></span></em>
</div>
</div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span>{{ 'hostProxyPatternName' | translate }}</span>
<i class="icon-primary fa fa-question-circle" data-toggle="popover"
data-trigger="hover" data-placement="auto right" data-container="body" data-html="true"
data-content="{{ 'hostProxyPatternDescription' | translate }}"></i>
</div>
<div class="setting-value col-sm-8">
<textarea class="form-control" rows="4" ng-model="context.settings.hostProxyPattern"
ng-change="setHostProxyPattern(context.settings.hostProxyPattern)" ng-keyup="inputKeyUp($event, true)"></textarea>
</div>
</div>
<div class="row" ng-if="isSupportNotification()">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Enable Browser Notification</span>
Expand Down

0 comments on commit 7405519

Please sign in to comment.