-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add host proxy pattern for global proxy configuration #752
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest you just write one example since you already mentioned one item per line |
||
'error': { | ||
'unknown': 'Unknown error occurred.', | ||
'operation.timeout': 'Operation timed out.', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,11 @@ | |
$rootScope.setTheme(value); | ||
}; | ||
|
||
$scope.setHostProxyPattern = function (value) { | ||
ariaNgSettingService.setHostProxyPattern(value); | ||
$rootScope.setProxyHostPattern(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need to call |
||
}; | ||
|
||
$scope.setDebugMode = function (value) { | ||
ariaNgSettingService.setDebugMode(value); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please format your code (a space should be appended to the left side of the equal symbol) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to check
|
||
if (proxyRegex) { | ||
var patterns = proxyRegex.split('\n'); | ||
for (var i = 0; i < patterns.length; i++) { | ||
patterns[i] = patterns[i].trim() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a semicolon at the end of the line |
||
if (patterns[i]) { | ||
var lastIndex = patterns[i].lastIndexOf('|'); | ||
if (lastIndex === -1) continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not write the if condition and the actual execution code on the same line. You can just write like the following code
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
} | ||
} | ||
} | ||
|
||
return invoke(buildRequestContext('addUri', context, urls, options), !!returnContextOnly); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the actual displayed content in English instead of placeholders to avoid unfriendly content that may be displayed when the language resources are not loaded. |
||
<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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AriaNgSettingsController does not have a function called "inputKeyUp", you can remove the |
||
</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> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a blank line before the header of a new group