Skip to content

Commit

Permalink
Reorder outbounds by filter settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Oct 11, 2023
1 parent 1c20cde commit 66a1c5e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,31 @@ func (p *Profile) GenerateConfig(platform string, version *Version, outbounds []
outbounds = common.Filter(outbounds, func(it option.Outbound) bool {
return common.Contains(p.filterOutbound, it.Tag)
})
newOutbounds := make([]option.Outbound, 0, len(outbounds))
for _, outboundTag := range p.filterOutbound {
for _, outbound := range outbounds {
if outbound.Tag == outboundTag {
newOutbounds = append(newOutbounds, outbound)
break
}
}
}
outbounds = newOutbounds
}
if len(p.filterSubscription) > 0 {
subscriptions = common.Filter(subscriptions, func(it *SubscriptionOptions) bool {
return common.Contains(p.filterSubscription, it.Name)
})
newSubscriptions := make([]*SubscriptionOptions, 0, len(subscriptions))
for _, subscriptionName := range p.filterSubscription {
for _, subscription := range subscriptions {
if subscription.Name == subscriptionName {
newSubscriptions = append(newSubscriptions, subscription)
break
}
}
}
subscriptions = newSubscriptions
}
if version != nil && ParseVersion("1.3-beta9").After(*version) {
outbounds = common.Filter(outbounds, filterH2Mux)
Expand Down

0 comments on commit 66a1c5e

Please sign in to comment.