Skip to content

Commit

Permalink
fix prepend outbound
Browse files Browse the repository at this point in the history
  • Loading branch information
hossinasaadi committed Oct 23, 2023
1 parent 74ca15e commit 4523b62
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions infra/conf/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,25 +504,24 @@ func (c *Config) Override(o *Config, fn string) {

// update the Outbound in slice if the only one in overide config has same tag
if len(o.OutboundConfigs) > 0 {
outboundPrepends := o.OutboundConfigs
outboundPrepends := []OutboundDetourConfig{}
for i := range o.OutboundConfigs {
if idx := c.findOutboundTag(o.OutboundConfigs[i].Tag); idx > -1 {
c.OutboundConfigs[idx] = o.OutboundConfigs[i]
outboundPrepends = append(c.OutboundConfigs[:idx], c.OutboundConfigs[idx+1:]...)
newError("[", fn, "] updated outbound with tag: ", o.OutboundConfigs[i].Tag).AtInfo().WriteToLog()
} else {
if strings.Contains(strings.ToLower(fn), "tail") {
c.OutboundConfigs = append(c.OutboundConfigs, o.OutboundConfigs[i])
newError("[", fn, "] appended outbound with tag: ", o.OutboundConfigs[i].Tag).AtInfo().WriteToLog()
} else {
// last item
if i == len(o.OutboundConfigs)-1 {
c.OutboundConfigs = append(o.OutboundConfigs, outboundPrepends...)
newError("[", fn, "] prepended outbounds ").AtInfo().WriteToLog()
}
outboundPrepends = append(outboundPrepends, o.OutboundConfigs[i])
newError("[", fn, "] prepend outbound with tag: ", o.OutboundConfigs[i].Tag).AtInfo().WriteToLog()
}
}
}
if !strings.Contains(strings.ToLower(fn), "tail") && len(outboundPrepends) > 0 {
c.OutboundConfigs = append(outboundPrepends, c.OutboundConfigs...)
}
}
}

Expand Down

0 comments on commit 4523b62

Please sign in to comment.