fallback outbound in balancer

Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
mhsanaei 2024-07-15 00:09:31 +02:00
parent 0a95b0c7b2
commit 816adfc3ea
2 changed files with 21 additions and 9 deletions

View File

@ -1268,7 +1268,8 @@
balancer: {
tag: '',
strategy: 'random',
selector: []
selector: [],
fallbackTag: ''
},
confirm: (balancer) => {
balancerModal.loading();
@ -1278,7 +1279,8 @@
}
let tmpBalancer = {
'tag': balancer.tag,
'selector': balancer.selector
'selector': balancer.selector,
'fallbackTag': balancer.fallbackTag
};
if (balancer.strategy && balancer.strategy != 'random') {
tmpBalancer.strategy = {
@ -1308,7 +1310,8 @@
let tmpBalancer = {
'tag': balancer.tag,
'selector': balancer.selector
'selector': balancer.selector,
'fallbackTag': balancer.fallbackTag
};
// Remove old tag
@ -1377,7 +1380,7 @@
this.changeObsCode();
},
deleteBalancer(index) {
let newTemplateSettings = { ...this.templateSettings };
newTemplateSettings = this.templateSettings;
// Remove from balancers
const removedBalancer = this.balancersData.splice(index, 1)[0];
@ -1623,7 +1626,8 @@
'key': index,
'tag': o.tag ? o.tag : "",
'strategy': o.strategy?.type ?? "random",
'selector': o.selector ? o.selector : []
'selector': o.selector ? o.selector : [],
'fallbackTag': o.fallbackTag?? '',
});
});
}

View File

@ -26,12 +26,18 @@
</a-select>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.balancer.balancerSelectors" }}' has-feedback
:validate-status="balancerModal.emptySelector? 'warning' : 'success'">
:validate-status="balancerModal.emptySelector? 'warning' : 'success'">
<a-select v-model="balancerModal.balancer.selector" mode="tags" @change="balancerModal.checkSelector()"
:dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="tag in balancerModal.outboundTags" :value="tag">[[ tag ]]</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="Fallback">
<a-select v-model="balancerModal.balancer.fallbackTag" clearable
:dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="tag in [ '', ...balancerModal.outboundTags]" :value="tag">[[ tag ]]</a-select-option>
</a-select>
</a-form-item>
</table>
</a-form>
</a-modal>
@ -48,7 +54,8 @@
balancer: {
tag: '',
strategy: 'random',
selector: []
selector: [],
fallbackTag: ''
},
outboundTags: [],
balancerTags:[],
@ -71,7 +78,8 @@
balancerModal.balancer = {
tag: '',
strategy: 'random',
selector: []
selector: [],
fallbackTag: ''
};
}
this.balancerTags = balancerTags.filter((tag) => tag != balancer.tag);