Skip to content
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

Override outbounds in multi config files #2659

Merged
merged 6 commits into from
Oct 24, 2023

Conversation

hossinasaadi
Copy link
Contributor

seems override outbounds should also consider in last PR #2655

if idx := c.findOutboundTag(o.OutboundConfigs[0].Tag); idx > -1 {
c.OutboundConfigs[idx] = o.OutboundConfigs[0]
ctllog.Println("[", fn, "] updated outbound with tag: ", o.OutboundConfigs[0].Tag)
outboundPrepends := o.OutboundConfigs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need outboundPrepends? this logic doesn't seem right to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you know when file name includes "tail", outbound configs will append to original config and if not, the override outbounds should prepend to original config.
in several test cases some outbounds of the original config will update if they have the same Tag name in :

c.OutboundConfigs[idx] = o.OutboundConfigs[i]

so if i use c.OutboundConfigs for prepend instead of outboundPrepends , it may cause of duplicate outbound with same tag name in final config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o.OutboundConfigs are incoming data, c.OutboundConfigs are existing data. While we iterate through o.OutboundConfigs there are three case:

  1. tag match, replace one of existing
  2. append
  3. prepend
    1 and 3 should not both happen for the same entry. Why it create duplicates?

Copy link
Contributor Author

@hossinasaadi hossinasaadi Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuhan6665 actually after write a lot of explanations ,suddenly realized what happened here. i think outboundPrepends seems reasonable now :)

@yuhan6665 yuhan6665 merged commit 67c66fa into XTLS:main Oct 24, 2023
35 checks passed
@yuhan6665
Copy link
Member

Looks good. Thanks!

@hossinasaadi hossinasaadi deleted the overrideOutbounds branch October 24, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants