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

feat: add priority for config loaders #2622

Closed
wants to merge 1 commit into from

Conversation

AkinoKaede
Copy link
Contributor

@AkinoKaede AkinoKaede commented Jul 25, 2023

related to #2620

V2Ray will try to use all config loaders if the config format isn't set. However, sometimes the config which written in other formats will be loaded as v4 format. A priority queue for loaders can solve this problem.

Priority Queue is not goroutine-safe, I think the priority queue will not be written after init().

@frankli0324
Copy link

frankli0324 commented Jul 25, 2023

I think this is not only over-engineered but also unable to fix the directory issue. the solution is simple as

diff --git a/main/commands/run.go b/main/commands/run.go
index 1e88b84..612d7af 100644
--- a/main/commands/run.go
+++ b/main/commands/run.go
@@ -119,9 +119,8 @@ func readConfDir(dirPath string, extension []string) cmdarg.Arg {
 	}
 	files := make(cmdarg.Arg, 0)
 	for _, f := range confs {
-		ext := filepath.Ext(f.Name())
 		for _, e := range extension {
-			if strings.EqualFold(e, ext) {
+			if strings.HasSuffix(f.Name(), e) {
 				files.Set(filepath.Join(dirPath, f.Name()))
 				break
 			}

image

@AkinoKaede
Copy link
Contributor Author

AkinoKaede commented Jul 25, 2023

I think this is not only over-engineered but also unable to fix the directory issue. the solution is simple as

diff --git a/main/commands/run.go b/main/commands/run.go
index 1e88b84..612d7af 100644
--- a/main/commands/run.go
+++ b/main/commands/run.go
@@ -119,9 +119,8 @@ func readConfDir(dirPath string, extension []string) cmdarg.Arg {
 	}
 	files := make(cmdarg.Arg, 0)
 	for _, f := range confs {
-		ext := filepath.Ext(f.Name())
 		for _, e := range extension {
-			if strings.EqualFold(e, ext) {
+			if strings.HasSuffix(f.Name(), e) {
 				files.Set(filepath.Join(dirPath, f.Name()))
 				break
 			}

image

The meaning of this modification solves the problem for users who do not know how to modify systemd files. I have received many related emails.

I think you can open an another PR.

@frankli0324
Copy link

then I believe a simple sort.Slice would suffice.

@AkinoKaede AkinoKaede closed this Oct 29, 2023
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