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

Bug: MultiFile Multi inbound issue #2606

Closed
hiddify-com opened this issue Oct 2, 2023 · 5 comments
Closed

Bug: MultiFile Multi inbound issue #2606

hiddify-com opened this issue Oct 2, 2023 · 5 comments

Comments

@hiddify-com
Copy link
Contributor

hiddify-com commented Oct 2, 2023

When we have multifile configuration with multi inbound, files with multiple inbounds will be ignored.

example:

x.json:

{
        "inbounds": [
       {
            "tag": "x1",
            "listen": "127.0.0.1",
            "port": 1001,
            "protocol": "socks"
        },
       {
            "tag": "x2",
            "listen": "127.0.0.1",
            "port": 1002,
            "protocol": "socks"
        }
        ]
}

y.json:

{
        "inbounds": [
       {
            "tag": "y1",
            "listen": "127.0.0.1",
            "port": 2001,
            "protocol": "socks"
        },
       {
            "tag": "y2",
            "listen": "127.0.0.1",
            "port": 2002,
            "protocol": "socks"
        }
        ]
}

z.json:

{
        "inbounds": [
       {
            "tag": "z1",
            "listen": "127.0.0.1",
            "port": 3001,
            "protocol": "socks"
        }
        ]
}

The Problem

Inbounds of y.json override the inbounds in xray so inbounds in x.json will be ignored.

I have tried to do pull request but i could not identify the source of the issue.

logs:

...
2023/10/02 12:40:03 [Info] infra/conf/serial: Reading config: x.json
2023/10/02 12:40:03 [Info] infra/conf/serial: Reading config: y.json
2023/10/02 12:40:03 [Info] infra/conf/serial: Reading config: z.json
xctl> [ z.json ] appended inbound with tag:  z1
2023/10/02 12:40:04 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:2001
2023/10/02 12:40:04 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:2002
2023/10/02 12:40:04 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:3001
2023/10/02 12:40:04 [Warning] core: Xray 1.8.4 started

@BioniCosmos
Copy link

@yuhan6665 I think we should revert changes #2655 and #2659 because the behaviour in the issue is expected.

The logic is inherited from V2Ray, so these are breaking changes.

多文件配置 | Project X

@BioniCosmos
Copy link

Furthermore, there are bugs when the tag is empty. For example, if there are two config files: 0_log.json and 1_inbounds.json.

{
  "log": {
    "loglevel": "info"
  }
}
{
  "inbounds": [
    {
      "port": 10000,
      "protocol": "socks"
    },
    {
      "port": 10001,
      "protocol": "socks"
    }
  ]
}

Only the port 10001 is listening, which is unexpected.

func (c *Config) findInboundTag(tag string) int {
	found := -1
	// Maybe we should add the following code.
	// if tag == "" {
	// 	return found
	// }

	for idx, ib := range c.InboundConfigs {
		if ib.Tag == tag {
			found = idx
			break
		}
	}
	return found
}

@yuhan6665
Copy link
Member

@BioniCosmos I think override behavior is ok. Please discuss with @hossinasaadi as well

@hossinasaadi
Copy link
Contributor

@BioniCosmos
https://xtls.github.io/config/features/multiple.html#%E6%95%B0%E7%BB%84
every inbound should have tag as you see in docs, if not the default tag name will be a empty string.
so when we add multiple config files, we identified inbound and outbounds with tag name (for update or replace them).

in your inbound file :

{
  "inbounds": [
    {
      "port": 10000,
      "protocol": "socks"
    },
    {
      "port": 10001,
      "protocol": "socks"
    }
  ]
}

two inbound tag names assigned as "" so the first one port will replaced with second inbound.

@BioniCosmos
Copy link

@hossinasaadi
Tags are not necessary. For example, I only want to set a simple Socks and HTTP server without tags. In such situation, override is unreasonable.

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

No branches or pull requests

5 participants